Arch4J 1.1

org.arch4j.property
Class StartupConstants

java.lang.Object
  |
  +--org.arch4j.property.StartupConstants
Direct Known Subclasses:
DefaultConstants

public abstract class StartupConstants
extends Object

This class defines methods that are used to initialize an application and to configure its runtime environment. This eases the burden of having to configure all of the runtime parameters as Java VM -D arguments. Only two are needed; one to point to a concrete subclass of this class and one to point to an application home directory. With those two properties set (either via a -D argument or via a servlet), the rest of the runtime configuration can be determined, either directly as additional methods on the subclass or indirectly through the property file values.

XML SAX properties are included and defaulted here to help insure that the XML properties can be parsed without having to set up additional Java VM arguments. XML parsing via the JAXP API is included when using version 1.4 or greater of the Java VM. If an older VM is used, make sure you include a JAXP-compliant SAX parser factory class in your classpath and modify your subclass to point to it.

Application developers should create their own subclass and override what they want.

Two system properties are used by the PropertyProvider when it is initialized by way of a subclass of this class.

The first property is named arch4j.constants.class. Its value is a class name, which is a subclass of this class. It is used to get the other startup properties.

The second property comes by way of the method 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.

For example, let us suppose that an application named counter is being deployed. The application will contain a subclass of StartupConstants named com.mycompany.counter.CounterStartupConstants. In addition to the application code, 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 counter.app.home, which is what the overridden method getApplicationHomeProperty() will return.

Here are the Java VM -D arguments that will initialize the application correctly.

 -Darch4j.constants.class=com.mycompany.counter.CounterStartupConstants
 -Dcounter.app.home=C:/var/appData/counter
 

If you really, really do not want to use an application home directory, do not set the application home system property (the -Dcounter.app.home in the example above). Also, force the default application home method getDefaultApplicationHome() to return a null. Just make sure to store the XML property file somewhere in your classpath. It will be found and parsed.

Version:
$Revision: 1.5 $
Author:
Ross E. Greinke

Field Summary
static String CONSTANTS_CLASS_PROPERTY
          The new-style property specifying the startup constants class name to use.
 
Constructor Summary
StartupConstants()
           
 
Method Summary
 String getApplicationHome()
          Returns a string containing the application home directory.
abstract  String getApplicationHomeProperty()
          Returns a string containing the application home directory property key.
 String getDefaultApplicationHome()
          Returns a string containing the default application home directory.
 String getDefaultXMLParserFactoryClassname()
          Returns a string containing the default SAX Parser Factory class name to use.
 String getPropertyFilename()
          Returns a string containing the name of the property file to use for startup.
 String getXMLParserFactoryProperty()
          Returns a string containing the property name to use to get a SAX Parser Factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONSTANTS_CLASS_PROPERTY

public static final String CONSTANTS_CLASS_PROPERTY
The new-style property specifying the startup constants class name to use.

See Also:
Constant Field Values
Constructor Detail

StartupConstants

public StartupConstants()
Method Detail

getApplicationHomeProperty

public abstract String getApplicationHomeProperty()
Returns a string containing the application home directory property key.

Returns:
A string containing the application home directory property key.

getDefaultApplicationHome

public String getDefaultApplicationHome()
Returns a string containing the default application home directory. Defaults to the value of the system property user.home.

Returns:
A string containing the default application home directory.

getPropertyFilename

public String getPropertyFilename()
Returns a string containing the name of the property file to use for startup. Defaults to properties.xml.

Returns:
A string containing the name of the property file to use for startup.

getXMLParserFactoryProperty

public String getXMLParserFactoryProperty()
Returns a string containing the property name to use to get a SAX Parser Factory. Defaults to javax.xml.parsers.SAXParserFactory.

Returns:
A string containing the property name to use to get a SAX Parser Factory.

getDefaultXMLParserFactoryClassname

public String getDefaultXMLParserFactoryClassname()
Returns a string containing the default SAX Parser Factory class name to use. Defaults to org.apache.crimson.jaxp.SAXParserFactoryImpl, the default implementation for J2SE 1.4.

Returns:
A string containing the default SAX Parser Factory class name to use.

getApplicationHome

public String getApplicationHome()
Returns a string containing the application home directory.

Returns:
A string containing the application home directory.

Arch4J 1.1

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