Arch4J 1.1
Class StartupServlet

All Implemented Interfaces:
Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

public class StartupServlet
extends javax.servlet.http.HttpServlet

This class is used to initialize property management for applications that run inside a web container. Since it is non-trivial to add Java VM -D arguments to the web container startup, this servlet class can be used at servlet initialization time to configure the system properties needed to bootstrap the PropertyProvider, specifically for XML property management, which is the new-style way of handling application configuration via Arch4J.

Using this servlet requires that a valid servlet section in the web.xml deployment file be set up to initialize this servlet. Along with the servlet name, two servlet initialization parameters must be made available to the servlet. These two parameters directly correspond to the two system properties that are used by the PropertyProvider when it is initialized.

The first parameter is named arch4j.constants.class. Its value is a class name, which is a subclass of StartupConstants. This class is used to get the other startup properties.

The second parameter comes by way of the method StartupConstants.getApplicationHomeProperty(). This string is the parameter name to use to find the application's home directory. The name chosen is up to the application developer, and it is the developer's responsibility to make sure that the name matches in both the web.xml deployment file and the constants subclass.

For example, let us suppose that a web application named counter is being deployed. The application will contain a subclass of StartupConstants named com.mycompany.counter.CounterStartupConstants. In addition to the web container archive, there is an external location for properties to be modified and data files to be stored. This application home directory will be located in C:/var/appData/counter. The developer arbitrarily chooses the application home property name to be, which is what the overridden method StartupConstants.getApplicationHomeProperty() will return.

To ensure that this happens when the web container starts the application, we will load this servlet on startup as the first loaded servlet. Here is the servlet section that will initialize the application correctly.


If you really, really do not want to use an application home directory, do not include the application home init parameter in your servlet specification ( in the example above). Also, force the default application home method StartupConstants.getDefaultApplicationHome() in your StartupConstants subclass to return a null. Just make sure to store the XML property file somewhere in your classpath. It will be found and parsed.

$Revision: 1.3 $
$Author: rgreinke $
See Also:
Serialized Form

Constructor Summary
Method Summary
 void init()
          This method handles the servlet initialization.
Methods inherited from class javax.servlet.http.HttpServlet
doDelete, doGet, doHead, doOptions, doPost, doPut, doTrace, getLastModified, service, service
Methods inherited from class javax.servlet.GenericServlet
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public StartupServlet()
Method Detail


public void init()
          throws javax.servlet.ServletException
This method handles the servlet initialization. Specifically, this method gets the initialization properties needed to start up the PropertyProvider from a web containter.

init in class javax.servlet.GenericServlet
javax.servlet.ServletException - if an exception occurs that interrupts the servlet's normal operation

Arch4J 1.1

Copyright © 2000-2004 SpiderLogic, a service of Wipfli Ullrich Bertelson LLP.