|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.cementj.base.ApplicationEnvironment
public abstract class ApplicationEnvironment
This class provides base functionality for managing configuration properties for applications.
This class assumes that your configuration file is a properties file (see java.util.Properties). If it isn't, you'll have to override the loadProperties method. More detail below.
By default, this class will look for updated properties on the first use after 10 minutes of the last check for updates. You can change this interval by overriding the method getUpdateTimeIntervalInMillis(). An example is provided.
To use this class, do the following:
protected String getConfigurationFileName() {return "myapp.properties";}
private static final SampleEnvironment _myEnvironment = new SampleEnvironment();
public static String getDatabaseConnectionPoolName() { return _myEnvironment.getProperty("db.pool"); }
protected long getUpdateTimeIntervalInMillis() {return 1200000;}
Copyright: Delta Vortex Technologies, 2003.
Field Summary | |
---|---|
static java.lang.String |
DEFAULT_CONFIG_FILE_NAME
|
static long |
DEFAULT_UPDATE_TIME_INTERVAL
The default update time interval for application properties is 10 minutes. |
Constructor Summary | |
---|---|
protected |
ApplicationEnvironment()
|
Method Summary | |
---|---|
protected abstract java.lang.String |
getConfigurationFileName()
Method to return the applications configuration property filename. |
protected java.lang.String |
getProperty(java.lang.String name)
Returns the value of a property from the environment. |
protected java.lang.String |
getProperty(java.lang.String name,
java.lang.String defaultValue)
Returns the value of a property from the environment. |
protected java.util.Enumeration |
getPropertyKeyEnumeration()
|
protected long |
getUpdateTimeIntervalInMillis()
Provides the refresh time interval used to check fo changes in the properties file. |
protected void |
loadProperties()
|
protected void |
loadProperties(java.util.Properties props)
Appends properties to the application property set. |
protected void |
setProperty(java.lang.String property,
java.lang.String value)
Sets a property in the environment. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final long DEFAULT_UPDATE_TIME_INTERVAL
public static final java.lang.String DEFAULT_CONFIG_FILE_NAME
Constructor Detail |
---|
protected ApplicationEnvironment()
Method Detail |
---|
protected java.lang.String getProperty(java.lang.String name)
name
-
protected java.lang.String getProperty(java.lang.String name, java.lang.String defaultValue)
name
- defaultValue
-
protected void setProperty(java.lang.String property, java.lang.String value)
property
- value
- protected void loadProperties()
protected void loadProperties(java.util.Properties props)
props
- protected java.util.Enumeration getPropertyKeyEnumeration()
protected abstract java.lang.String getConfigurationFileName()
protected long getUpdateTimeIntervalInMillis()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |