|
SolarMetric Kodo JDO 3.1.6 generated on August 25 2004 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.solarmetric.conf.ConfigurationImpl
Default implementation of the Configuration interface.
Subclasses can choose to obtain configuration
information from JNDI, Properties, a Bean-builder, etc. This class
provides base configuration functionality, including serialization,
the equals and hashCode contracts, and default
property loading.
On construction, the class will attempt to locate a default properties
file called solarmetric.properties located at any top level
token of the CLASSPATH. The name of the properties file can be
overridden.
Subclasses should be sure to pass in false to the
constructor when they call it, then call loadDefaults() themselves
if they want to load default properties. Otherwise, their field
initializations will overwrite the defaults that were loaded.
Property descriptors for Value instances are constructed from
the Localizer for the package of the configuration class. The
following localized strings will be used for describing a value, where
name is the last token of the value's property string:
| Field Summary | |
protected LogFactory |
logFactory
|
| Fields inherited from interface com.solarmetric.conf.Configuration |
ATTRIBUTE_ALLOWED_VALUES, ATTRIBUTE_TYPE |
| Fields inherited from interface java.beans.BeanInfo |
ICON_COLOR_16x16, ICON_COLOR_32x32, ICON_MONO_16x16, ICON_MONO_32x32 |
| Constructor Summary | |
ConfigurationImpl()
Default constructor. |
|
ConfigurationImpl(boolean loadDefaults)
Constructor. |
|
| Method Summary | |
protected BooleanValue |
addBoolean(String property)
Add the given value to the set of configuration properties. |
protected DoubleValue |
addDouble(String property)
Add the given value to the set of configuration properties. |
protected IntValue |
addInt(String property)
Add the given value to the set of configuration properties. |
protected PluginValue |
addPlugin(String property)
Add the given value to the set of configuration properties. |
protected PluginListValue |
addPluginList(String property)
Add the given value to the set of configuration properties. |
protected StringValue |
addString(String property)
Add the given value to the set of configuration properties. |
protected StringListValue |
addStringList(String property)
Add the given value to the set of configuration properties. |
protected Value |
addValue(Value val)
Add the given value to the set of configuration properties. |
protected void |
assertNotFrozen()
Checks if the configuration has been frozen and if so throws a IllegalStateException, otherwise returns silently. |
void |
close()
Free the resources used by this object. |
boolean |
equals(Object other)
Performs an equality check based on the properties returned from toProperties(). |
void |
fromProperties(Properties props)
Fill in values from the given properties instance. |
void |
fromStream(InputStream in)
Fill in properties from the given properties input stream. |
BeanInfo[] |
getAdditionalBeanInfo()
|
BeanDescriptor |
getBeanDescriptor()
|
RuntimeException |
getConfigurationException(String msg,
Throwable cause)
Throws a standard or nestable runtime exception by default. |
Log |
getConfigurationLog()
Reutrns the logging channel com.solarmetric.Runtime by
default. |
int |
getDefaultEventIndex()
|
int |
getDefaultPropertyIndex()
|
EventSetDescriptor[] |
getEventSetDescriptors()
|
Image |
getIcon(int kind)
|
Log |
getLog(String category)
Return the log for the given category. |
LogFactory |
getLogFactory()
The log factory. |
MethodDescriptor[] |
getMethodDescriptors()
|
protected String |
getProductName()
Return the product name. |
PropertyDescriptor[] |
getPropertyDescriptors()
|
Value |
getValue(String property)
Return a Value for a given property. |
Value[] |
getValues()
Return the set of all Values. |
int |
hashCode()
Computes hash code based on the properties returned from toProperties(). |
boolean |
isCaching()
Return whether Properties conversions are cached. |
boolean |
isFrozen()
Return true if the configuration has been frozen. |
protected boolean |
isInvalidProperty(String propName)
Returns true if the specified property name should raise a warning if it is not found in the list of known properties. |
boolean |
loadDefaults()
Invoke this method to load default values from properties. |
void |
readExternal(ObjectInput in)
Implementation of the Externalizable interface to read from
the properties written by writeExternal(java.io.ObjectOutput). |
void |
setCaching(boolean caching)
Set whether to optimize Properties conversion
by caching Value states. |
void |
setFrozen(boolean frozen)
Following a call to this method, calls to assertNotFrozen() will
throw an exception. |
void |
setLogFactory(LogFactory logFactory)
log factory. |
void |
setProperties(String resourceName)
This method loads the named resource as a properties file. |
void |
setPropertiesFile(File file)
This method loads the named file as a properties file. |
Properties |
toProperties()
Properties objects are cached once created so that calls to this method are relatively cheap (the properties object is still cloned for each call). |
void |
writeExternal(ObjectOutput out)
Implementation of the Externalizable interface to write
the properties returned by toProperties(). |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected LogFactory logFactory
| Constructor Detail |
public ConfigurationImpl()
solarmetric.properties resource. Override the
getProductName() method to change the name of the default
properties resource.public ConfigurationImpl(boolean loadDefaults)
loadDefaults - whether to attempt to load the default
solarmetric.properties resource| Method Detail |
public void setLogFactory(LogFactory logFactory)
ConfigurationsetLogFactory in interface Configurationpublic LogFactory getLogFactory()
ConfigurationgetLogFactory in interface Configurationpublic Log getLog(String category)
ConfigurationgetLog in interface Configurationcom.solarmetric.conf.ConfigurationConfiguration.getLogFactory()public Value getValue(String property)
ConfigurationValue for a given property.getValue in interface Configurationpublic Value[] getValues()
ConfigurationValues.getValues in interface Configurationpublic BeanInfo[] getAdditionalBeanInfo()
getAdditionalBeanInfo in interface BeanInfopublic BeanDescriptor getBeanDescriptor()
getBeanDescriptor in interface BeanInfopublic int getDefaultEventIndex()
getDefaultEventIndex in interface BeanInfopublic int getDefaultPropertyIndex()
getDefaultPropertyIndex in interface BeanInfopublic EventSetDescriptor[] getEventSetDescriptors()
getEventSetDescriptors in interface BeanInfopublic Image getIcon(int kind)
getIcon in interface BeanInfopublic MethodDescriptor[] getMethodDescriptors()
getMethodDescriptors in interface BeanInfopublic PropertyDescriptor[] getPropertyDescriptors()
getPropertyDescriptors in interface BeanInfopublic void close()
Configurationclose in interface Configurationprotected String getProductName()
solarmetric.loadDefaults()public boolean loadDefaults()
<product-name>.properties system
property for the location of a properties file to parse, where
product-name is the return value of the
getProductName() method. If no system property is defined,
the default resource location of
<product-name>.properties is used. If it exists,
the resource is parsed as a properties file. All system properties
are then added; they override any same-named properties in the
resource. The combined properties are then loaded into this
configuration.ClassLoader.getResource(java.lang.String)public void setCaching(boolean caching)
ConfigurationProperties conversion
by caching Value states.setCaching in interface Configurationpublic boolean isCaching()
ConfigurationProperties conversions are cached.isCaching in interface Configurationpublic void setFrozen(boolean frozen)
assertNotFrozen() will
throw an exception. This method is meant to lock down the
configuration; subclasses should therefore call assertNotFrozen()
as the first line in all mutator methods.setFrozen in interface Configurationpublic boolean isFrozen()
isFrozen in interface Configurationpublic Properties toProperties()
assertNotFrozen(), because it precedes all state changes.toProperties in interface ConfigurationConfiguration.toProperties()public void fromProperties(Properties props)
fromProperties in interface Configurationprotected boolean isInvalidProperty(String propName)
public Log getConfigurationLog()
com.solarmetric.Runtime by
default.getConfigurationLog in interface Configuration
public RuntimeException getConfigurationException(String msg,
Throwable cause)
getConfigurationException in interface Configuration
public void fromStream(InputStream in)
throws IOException
public void setProperties(String resourceName)
throws IOException
properties value with the name of a resource.
public void setPropertiesFile(File file)
throws IOException
propertiesFile value with the name of a file.protected void assertNotFrozen()
IllegalStateException, otherwise returns silently.
Implementations should call this method before setting any state.public boolean equals(Object other)
toProperties().equals in class Objectpublic int hashCode()
toProperties().hashCode in class Object
public void readExternal(ObjectInput in)
throws IOException,
ClassNotFoundException
Externalizable interface to read from
the properties written by writeExternal(java.io.ObjectOutput).readExternal in interface Externalizable
public void writeExternal(ObjectOutput out)
throws IOException
Externalizable interface to write
the properties returned by toProperties().writeExternal in interface Externalizableprotected Value addValue(Value val)
protected StringValue addString(String property)
protected IntValue addInt(String property)
protected DoubleValue addDouble(String property)
protected BooleanValue addBoolean(String property)
protected StringListValue addStringList(String property)
protected PluginValue addPlugin(String property)
protected PluginListValue addPluginList(String property)
|
SolarMetric Kodo JDO 3.1.6 generated on August 25 2004 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||