|
Arch4J 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.arch4j.property.StartupConstants
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.
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 |
public static final String CONSTANTS_CLASS_PROPERTY
Constructor Detail |
public StartupConstants()
Method Detail |
public abstract String getApplicationHomeProperty()
public String getDefaultApplicationHome()
user.home
.
public String getPropertyFilename()
properties.xml
.
public String getXMLParserFactoryProperty()
javax.xml.parsers.SAXParserFactory
.
public String getDefaultXMLParserFactoryClassname()
org.apache.crimson.jaxp.SAXParserFactoryImpl
, the
default implementation for J2SE 1.4.
public String getApplicationHome()
|
Arch4J 1.1 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |