|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.griphyn.common.util.VDSProperties
public class VDSProperties
This class creates a common interface to handle package properties. The package properties are meant as read-only (so far, until requirements crop up for write access). The class is implemented as a Singleton pattern.
| Field Summary | |
|---|---|
private File |
m_dataDir
GNU: read-only architecture-independent data in DIR [PREFIX/share]. |
private String |
m_home
internal copy of a system property. |
private static VDSProperties |
m_instance
implements the singleton access via class variable. |
private File |
m_localStateDir
GNU: modifiable single-machine data in DIR [PREFIX/var]. |
private Properties |
m_props
internal set of properties. |
private File |
m_sharedStateDir
GNU: modifiable architecture-independent data in DIR [PREFIX/com]. |
private File |
m_sysConfDir
GNU: read-only single-machine data in DIR [PREFIX/etc]. |
static String |
OLD_USER_PROPERTY_FILENAME
Basename of the (old) file to read for user properties. |
static String |
PROPERTY_FILENAME
Basename of the file to read to obtain system properties |
static String |
USER_PROPERTY_FILENAME
Basename of the (new) file to read for user properties. |
| Constructor Summary | |
|---|---|
protected |
VDSProperties(String propFilename)
ctor. |
| Method Summary | |
|---|---|
protected static Properties |
addProperties(Properties a,
Properties b)
Adds new properties to an existing set of properties while substituting variables. |
private static Properties |
defaultProps()
Set some defaults, should values be missing in the dataset. |
File |
getDataDir()
Accessor to $PEGASUS_HOME/share. |
File |
getLocalStateDir()
Accessor to $PEGASUS_HOME/var. |
String |
getPegasusHome()
Accessor: Obtains the root directory of the Pegasus runtime system. |
String |
getProperty(String key)
Accessor: access to the internal properties as read from file. |
String |
getProperty(String key,
String defValue)
Accessor: access to the internal properties as read from file An existing system property of the same key will have precedence over any project property. |
File |
getSharedStateDir()
Accessor to $PEGASUS_HOME/com. |
File |
getSysConfDir()
Accessor to $PEGASUS_HOME/etc. |
String |
getVDSHome()
Accessor: Obtains the root directory of the VDS runtime system. |
static VDSProperties |
instance()
Singleton threading: Creates the one and only instance of the properties in the current application. |
static Properties |
matchingSubset(Properties properties,
String prefix,
boolean keepPrefix)
Extracts a specific property key subset from the properties passed. |
Properties |
matchingSubset(String prefix,
boolean keepPrefix)
Extracts a specific property key subset from the known properties. |
static VDSProperties |
noHassleInstance()
Singleton interface: Creates the one and only instance of the properties in the current application, and does not bother the programmer with exceptions. |
static VDSProperties |
nonSingletonInstance(String propFilename)
Create a temporary property that is not attached to the Singleton. |
Enumeration |
propertyNames()
Accessor: enumerate all keys known to this property collection |
Object |
setProperty(String key,
String value)
Accessor: Overwrite any properties from within the program. |
int |
size()
Accessor: Obtains the number of properties known to the project. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static VDSProperties m_instance
private Properties m_props
private String m_home
private File m_dataDir
private File m_sysConfDir
private File m_sharedStateDir
private File m_localStateDir
public static final String PROPERTY_FILENAME
public static final String OLD_USER_PROPERTY_FILENAME
public static final String USER_PROPERTY_FILENAME
| Constructor Detail |
|---|
protected VDSProperties(String propFilename)
throws IOException,
MissingResourceException
propFilename - is the basename of the file to read. This file
will be looked for in the $PEGASUS_HOME/etc directory. Usually, the name
will be set from the PROPERTY_FILENAME constant above.
Alternatively, the name will be ignored, if an alternative properties
location is specified via -Dpegasus.properties.
IOException - will be thrown if reading the property file
goes awry.
MissingResourceException - will be thrown if you forgot
to specify the -Dpegasus.home=$PEGASUS_HOME to the runtime
environment.| Method Detail |
|---|
protected static Properties addProperties(Properties a,
Properties b)
a - is the initial set of known properties (besides System ones)b - is the set of properties to add to a
private static Properties defaultProps()
public static VDSProperties instance()
throws IOException,
MissingResourceException
IOException - will be thrown if reading the property file
goes awry.
MissingResourceException - will be thrown if you forgot
to specify the -Dpegasus.home=$PEGASUS_HOME to the runtime
environment.noHassleInstance()
public static VDSProperties nonSingletonInstance(String propFilename)
throws IOException,
MissingResourceException
propFilename - is the full path name to the location of the
properties file to read. In case of null, the default location
will be taken
IOException - will be thrown if reading the property file
goes awry.
MissingResourceException - will be thrown if you forgot
to specify the -Dpegasus.home=$PEGASUS_HOME to the runtime
environment.instance()public static VDSProperties noHassleInstance()
instance() call are caught, converted to an error
message on stderr, and the program is exited.
instance()public String getVDSHome()
public String getPegasusHome()
public File getDataDir()
public File getSysConfDir()
public File getSharedStateDir()
public File getLocalStateDir()
public int size()
public String getProperty(String key)
key - is the key to look up
public String getProperty(String key,
String defValue)
key - is the key to look updefValue - is a default to use, if no value can be found for the key.
public Object setProperty(String key,
String value)
key - is the key to look upvalue - is the new property value to place in the system.
public Enumeration propertyNames()
public Properties matchingSubset(String prefix,
boolean keepPrefix)
prefix - is the key prefix to filter the properties by.keepPrefix - if true, the key prefix is kept in the resulting
dictionary. As side-effect, a key that matches the prefix exactly
will also be copied. If false, the resulting dictionary's keys are
shortened by the prefix. An exact prefix match will not be copied,
as it would result in an empty string key.
is used to assemble matches
public static Properties matchingSubset(Properties properties,
String prefix,
boolean keepPrefix)
prefix - is the key prefix to filter the properties by.keepPrefix - if true, the key prefix is kept in the resulting
dictionary. As side-effect, a key that matches the prefix exactly
will also be copied. If false, the resulting dictionary's keys are
shortened by the prefix. An exact prefix match will not be copied,
as it would result in an empty string key.
is used to assemble matches
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||