|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectraccoon.core.types.AbsComponent
raccoon.core.types.AbsLoadable
raccoon.core.types.AbsConfigurableLoadable
raccoon.core.config.StdConfig
public class StdConfig
Improvement to the java.util.PropertyResourceBundle.
CoreHelper.getConfig() methods. The IConfig
properties can be refreshed (i.e. reread from disk) by calling the
refresh() method.
log4j.appender.Raccoon = org.apache.log4j.RollingFileAppender
log4j.appender.Raccoon.File = Raccoon.log
log4j.appender.Raccoon.Append = false
log4j.appender.Raccoon.MaxFileSize = 5MB
log4j.appender.Raccoon.MaxBackupIndex = 10
log4j.appender.Raccoon.layout = org.apache.log4j.PatternLayout
log4j.appender.Raccoon.layout.ConversionPattern = %r [%t] %-5p %c{2} %x - %m %n
log4j.rootCategory=debug, Raccoon
RaccoonException if this component isn't active.
| Field Summary | |
|---|---|
static java.lang.String |
PTY_PROPERTY_FILE_NAME
The name of the java property bean containing the resource file name. |
| Fields inherited from class raccoon.core.types.AbsConfigurableLoadable |
|---|
mConfigurableManager |
| Fields inherited from class raccoon.core.types.AbsLoadable |
|---|
mIsLoaded |
| Fields inherited from class raccoon.core.types.AbsComponent |
|---|
mIsInError |
| Fields inherited from interface raccoon.api.config.IConfig |
|---|
PTY_CONFIG |
| Constructor Summary | |
|---|---|
StdConfig()
Default constructor, required by all components for dynamic instanciation. |
|
StdConfig(boolean pBootStrap)
Instanciates this component and if necessary boot straps. |
|
| Method Summary | |
|---|---|
void |
configureParameters()
Configures the various parameters for this component. |
boolean |
getBoolean(java.lang.String pProperty)
Reads the value of the propery and converts it to a boolean. |
boolean |
getBoolean(java.lang.String pProperty,
boolean pDefaultValue)
Reads the value of the propery and converts it to a boolean. |
double |
getDouble(java.lang.String pProperty)
Reads the value of the propery and converts it to a double. |
double |
getDouble(java.lang.String pProperty,
double pDefaultValue)
Reads the value of the propery and converts it to a double. |
int |
getInt(java.lang.String pProperty)
Reads the value of the propery and converts it to a integer. |
int |
getInt(java.lang.String pProperty,
int pDefaultValue)
Reads the value of the propery and converts it to a integer. |
long |
getLong(java.lang.String pProperty)
Reads the value of the propery and converts it to a long. |
long |
getLong(java.lang.String pProperty,
long pDefaultValue)
Reads the value of the propery and converts it to a long. |
(package private) java.lang.String |
getMissingPropertyMsg(java.lang.String pDesiredProperty)
Creates an error message to inform the developper that a property is missing from his file. |
java.util.Properties |
getProperties()
Extracts all the available properties to a convenient format. |
java.lang.String |
getPropertyFileName()
The property file used by this configuration instance |
java.lang.String |
getString(java.lang.String pProperty)
Reads the value of the propery and converts it to a String. |
java.lang.String |
getString(java.lang.String pProperty,
java.lang.Object[] pParams)
Retrieves a Message String from the configuration file and
converts it into a String. |
java.lang.String |
getString(java.lang.String pProperty,
java.lang.Object[] pParams,
java.lang.String pDefaultValue)
Retrieves a Message String from the configuration file and
converts it into a String. |
java.lang.String |
getString(java.lang.String pProperty,
java.lang.String pDefaultValue)
Reads the value of the propery and converts it to a String. |
java.util.StringTokenizer |
getStrings(java.lang.String pProperty)
Reads the value of the property and returns a StringTokenizer object. |
boolean |
isAvailable(java.lang.String pProperty)
Convenience method to check if a specific property is defined. |
void |
load()
Loads or initializes the component. |
void |
refresh()
Reload the properties from the properties file. |
void |
setPropertyFileName(java.lang.String pPropertyFileName)
Defines the name of the property file. |
| Methods inherited from class raccoon.core.types.AbsConfigurableLoadable |
|---|
isStable, setConfigurableManager, setLogger |
| Methods inherited from class raccoon.core.types.AbsLoadable |
|---|
getLog, isInError, isInitialised, isRunning, unload |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String PTY_PROPERTY_FILE_NAME
| Constructor Detail |
|---|
public StdConfig()
public StdConfig(boolean pBootStrap)
throws RaccoonException
pBootStrap - boot strap ?
RaccoonException - if the boot strap fails.| Method Detail |
|---|
public void configureParameters()
IConfigurableManager provided during the invocation
of AbsConfigurableLoadable.setConfigurableManager(IConfigurableManager).
configureParameters in interface IConfigurableconfigureParameters in class AbsConfigurableLoadablepublic java.lang.String getPropertyFileName()
public void setPropertyFileName(java.lang.String pPropertyFileName)
throws ResourceNotFoundException
pPropertyFileName - the file to use.
ResourceNotFoundException - if there is an internal error.
public void load()
throws java.lang.IllegalStateException,
LoadableException
load in interface ILoadableload in class AbsConfigurableLoadableLoadableException - if the component couldn't load itself.
java.lang.IllegalStateException - if the component isn't in a state to load itself. for example it is already loaded.java.lang.String getMissingPropertyMsg(java.lang.String pDesiredProperty)
pDesiredProperty - the missing property
public boolean isAvailable(java.lang.String pProperty)
throws RaccoonException
isAvailable in interface IConfigpProperty - the property to search for.
RaccoonException - if this component is active.
public boolean getBoolean(java.lang.String pProperty)
throws RaccoonException,
java.lang.NumberFormatException
true if the value of the property
is a String(true) or is 1.
This method will return false if the value of the property
is a String(false) or is 0.
- Specified by:
getBoolean in interface IConfig
- Parameters:
pProperty - the property to look for
- Returns:
- the boolean value for the requested property
- Throws:
RaccoonException - if the property couldn't be found
java.lang.NumberFormatException - if the specified property isn't a boolean.
public boolean getBoolean(java.lang.String pProperty,
boolean pDefaultValue)
true if the value of the property
is a String(true) or is 1.
This method will return false if the value of the property
is a String(false) or is 0.
This method will return pDefaultvalue if any error occurs.
- Specified by:
getBoolean in interface IConfig
- Parameters:
pProperty - the property to look forpDefaultValue - the default value returned if the property is not
found in the config file
- Returns:
- the boolean value for the requested property
public int getInt(java.lang.String pProperty)
throws RaccoonException,
java.lang.NumberFormatException
getInt in interface IConfigpProperty - the property to look for
RaccoonException - if the property couldn't be found
java.lang.NumberFormatException - if the specified property isn't a int.
public int getInt(java.lang.String pProperty,
int pDefaultValue)
pDefaultvalue if any error occurs.
getInt in interface IConfigpProperty - the property to look forpDefaultValue - the default value returned if the property is not
found in the config file
public long getLong(java.lang.String pProperty)
throws RaccoonException,
java.lang.NumberFormatException
getLong in interface IConfigpProperty - the property to look for
RaccoonException - if the property couldn't be found
java.lang.NumberFormatException - if the specified property isn't a long.
public long getLong(java.lang.String pProperty,
long pDefaultValue)
pDefaultvalue if any error occurs.
getLong in interface IConfigpProperty - the property to look forpDefaultValue - the default value returned if the property is not
found in the config file
public double getDouble(java.lang.String pProperty)
throws RaccoonException
getDouble in interface IConfigpProperty - the property to look for
RaccoonException - if the value can't be found or is invalid.
public double getDouble(java.lang.String pProperty,
double pDefaultValue)
pDefaultvalue if any error occurs.
getDouble in interface IConfigpProperty - the property to look forpDefaultValue - the default value returned if the property is not
found in the config file
public java.util.StringTokenizer getStrings(java.lang.String pProperty)
throws RaccoonException
getStrings in interface IConfigpProperty - the property for which the data is required.
RaccoonException - if the property couldn't be found.
public java.lang.String getString(java.lang.String pProperty)
throws RaccoonException
getString in interface IConfigpProperty - the property to look for
RaccoonException - if the value is an invalid String
public java.lang.String getString(java.lang.String pProperty,
java.lang.String pDefaultValue)
pDefaultvalue if any error occurs.
getString in interface IConfigpProperty - the property to look forpDefaultValue - the default value returned if the property is not
found in the config file
public java.lang.String getString(java.lang.String pProperty,
java.lang.Object[] pParams)
throws RaccoonException
Message String from the configuration file and
converts it into a String.
A Message String is a specific String, because
each occurrence of {i} in that String will be replaced by
Object[i].toString()
For example:
property = "Hello {0}, you have {1}, new Object[] {"Kathleen", "mail"}
String being returned:
"Hello Kathleen, you have mail"
No matter what the implementation behind the scenes is.
getString in interface IConfigpProperty - the property that is to be retrieved.pParams - a list of objects implementing the toString() method that
will be inserted into the resulting String
RaccoonException - if this method fails
public java.lang.String getString(java.lang.String pProperty,
java.lang.Object[] pParams,
java.lang.String pDefaultValue)
Message String from the configuration file and
converts it into a String.
A Message String is a specific String, because
each occurrence of {i} in that String will be replaced by
Object[i].toString()
For example:
property = "Hello {0}, you have {1}, new Object[] {"Kathleen", "mail"}
String being returned:
"Hello Kathleen, you have mail"
No matter what the implementation behind the scenes is.
This method will return pDefaultvalue if any error occurs.
getString in interface IConfigpProperty - the property that is to be retrieved.pParams - a list of objects implementing the toString() method that
will be inserted into the resulting StringpDefaultValue - the default value returned if the property is not
found in the config file
public void refresh()
throws RaccoonException
refresh in interface IConfigRaccoonException - if this component hasn't been initialised.
public java.util.Properties getProperties()
throws RaccoonException
getProperties in interface IConfigProperties object
RaccoonException - if the component isn't active
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||