|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.locomotive.server.Config
The Config class provides a way to maintain configuration information. It contains it's own error checking, and can return configuration in either an integer or String form. Any configs in a config file must have defuaults specified in the setupDefaults() method. So, to create your own config, you would have to override this method to setup your own set of configs.
The config file should specify first the name of the config, followed by at least one space, and then the value. For example:
SYSTEM_INSTANCE_ID sv_oneAll lines which begin with an '#' are read as comments, i.e. they are not evaluated.
Field Summary | |
static java.lang.String |
BEAN
When the config_file_path is equal to this, it indicates that the configuration was loaded from the BeanDirectory services, not a config file. |
java.lang.String |
forint
a constraint for use in the addConfig method which will check to make sure the value of the config is not empty or null, and is an integer |
java.lang.String |
forstring
a constraint for use in the addConfig method which will check to make sure the value of the config is neither empty nor null. |
Constructor Summary | |
Config()
Constructor for Bean Directory. |
|
Config(java.lang.String[] args,
java.lang.String defaultpath)
Initializes a config object, with the specified arguments, from the specified file path. |
Method Summary | |
protected void |
addConfig(java.lang.String name,
java.lang.String val,
java.lang.String conslist,
java.lang.String desc)
This method will allow you to add a config, regardless of whether or not it exists in the defaults, or in the config file |
java.lang.String |
changeConfig(java.lang.String name,
java.lang.String value)
this method changes an already created config to a specified value. |
void |
doConfigDump()
prints all the configs and their present values, along with their description, to standard out. |
java.lang.Integer |
genericGetInteger(java.lang.String name)
|
java.lang.String |
genericGetString(java.lang.String name)
|
void |
genericSet(java.lang.String name,
java.lang.String val)
|
void |
genericSetInteger(java.lang.String name,
java.lang.Integer val)
|
void |
genericSetString(java.lang.String name,
java.lang.String val)
|
java.lang.String |
getConfigFilePath()
returns the path of the file the config is read in from. |
java.util.Enumeration |
getConfigNamesEnumeration()
returns an enumeration of all the config names |
int |
getInt(java.lang.String name)
returns the value of a config as an int, if possible |
java.lang.String |
getString(java.lang.String name)
returns the value of a config as a string |
void |
init(java.lang.String[] args,
java.lang.String defaultpath)
|
protected boolean |
isComment(java.lang.String s)
returns true if the first character of the string is '#' |
protected java.lang.String |
loadConfigsFromFile(java.lang.String filename)
actually reads in the file and loads the configs. |
static void |
printsyntax(java.lang.String s)
prints the usage for arguments accepted by the constructor for this object |
void |
setupDefaults()
Override this method to set up your own defaults. |
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 BEAN
public java.lang.String forint
public java.lang.String forstring
Constructor Detail |
public Config(java.lang.String[] args, java.lang.String defaultpath) throws java.lang.IllegalArgumentException
args
- a series of srguments may be specified at construction.
these include:defaultpath
- the path of the config file to load. If equal to
the constant BEAN, no config file is used.public Config()
Method Detail |
public void init(java.lang.String[] args, java.lang.String defaultpath) throws java.lang.IllegalArgumentException
public void genericSetInteger(java.lang.String name, java.lang.Integer val)
public void genericSetString(java.lang.String name, java.lang.String val)
public void genericSet(java.lang.String name, java.lang.String val)
public java.lang.Integer genericGetInteger(java.lang.String name)
public java.lang.String genericGetString(java.lang.String name)
public void setupDefaults()
addConfig(java.lang.String, java.lang.String, java.lang.String, java.lang.String)
public java.lang.String getConfigFilePath()
protected void addConfig(java.lang.String name, java.lang.String val, java.lang.String conslist, java.lang.String desc)
name
- the name of the configval
- the value of the configconslist
- the list of constraints to apply to a config
value when it is loaded. Constraint usage follows that for the
org.locomotive.util.StringConstraint. Two values are provided in this
class - forint and forstring.desc
- a short description of the configStringConstraint
public java.lang.String changeConfig(java.lang.String name, java.lang.String value) throws ConfigNotFoundException, ConfigInitializationException
name:
- the name of the configvalue
- the new value for the config.public java.lang.String getString(java.lang.String name) throws ConfigNotFoundException
public int getInt(java.lang.String name) throws ConfigNotFoundException
public void doConfigDump()
protected boolean isComment(java.lang.String s)
protected java.lang.String loadConfigsFromFile(java.lang.String filename)
public static void printsyntax(java.lang.String s)
public java.util.Enumeration getConfigNamesEnumeration()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |