|
SolarMetric Kodo JDO 3.4.1 generated on May 30 2006 | ||||||||
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_CATEGORY, ATTRIBUTE_ORDER, 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 FileValue |
addFile(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. |
void |
addPropertyChangeListener(PropertyChangeListener listener)
Adds a listener for any property changes. |
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. |
Object |
clone()
Return a copy of the current configuration. |
void |
close()
Free the resources used by this object. |
boolean |
equals(Object other)
Performs an equality check based on the properties returned from toProperties(boolean) . |
void |
fromFile(File f)
Fill in properties from the given properties file. |
void |
fromProperties(Properties props)
Fill in values from the given properties instance. |
void |
fromStream(InputStream in)
Fill in properties from the given properties 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 the Value for the given property, or null if none. |
Value[] |
getValues()
Return the set of all Value s. |
int |
hashCode()
Computes hash code based on the properties returned from toProperties(boolean) . |
boolean |
hasJava5()
Return true if this VM has Java 5 features; otherwise
returns false . |
boolean |
isFrozen()
Return true if this 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 |
removePropertyChangeListener(PropertyChangeListener listener)
Removes a listener for any property changes. |
void |
setFrozen(boolean frozen)
Lock down the configuration's state. |
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(boolean storeDefaults)
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 |
valueChanged(Value val)
Callback used by Value objects to notify listener of
change. |
void |
writeExternal(ObjectOutput out)
Implementation of the Externalizable interface to write
the properties returned by toProperties(boolean) . |
Methods inherited from class java.lang.Object |
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
resourceMethod Detail |
protected 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 setLogFactory(LogFactory logFactory)
Configuration
setLogFactory
in interface Configuration
public LogFactory getLogFactory()
Configuration
getLogFactory
in interface Configuration
public Log getLog(String category)
Configuration
getLog
in interface Configuration
com.solarmetric.conf.Configuration
Configuration.getLogFactory()
public Value[] getValues()
Configuration
Value
s.getValues
in interface Configuration
public Value getValue(String property)
Configuration
Value
for the given property, or null if none.getValue
in interface Configuration
public void setFrozen(boolean frozen)
Configuration
IllegalStateException
.setFrozen
in interface Configuration
public boolean isFrozen()
Configuration
isFrozen
in interface Configuration
public void addPropertyChangeListener(PropertyChangeListener listener)
Configuration
addPropertyChangeListener
in interface Configuration
com.solarmetric.conf.Configuration
listener
- the listener to receive notification
of property changespublic void removePropertyChangeListener(PropertyChangeListener listener)
Configuration
removePropertyChangeListener
in interface Configuration
com.solarmetric.conf.Configuration
listener
- the listener to removepublic void valueChanged(Value val)
ValueListener
Value
objects to notify listener of
change.valueChanged
in interface ValueListener
public void close()
Configuration
close
in interface Configuration
public BeanInfo[] getAdditionalBeanInfo()
getAdditionalBeanInfo
in interface BeanInfo
public BeanDescriptor getBeanDescriptor()
getBeanDescriptor
in interface BeanInfo
public int getDefaultEventIndex()
getDefaultEventIndex
in interface BeanInfo
public int getDefaultPropertyIndex()
getDefaultPropertyIndex
in interface BeanInfo
public EventSetDescriptor[] getEventSetDescriptors()
getEventSetDescriptors
in interface BeanInfo
public Image getIcon(int kind)
getIcon
in interface BeanInfo
public MethodDescriptor[] getMethodDescriptors()
getMethodDescriptors
in interface BeanInfo
public PropertyDescriptor[] getPropertyDescriptors()
getPropertyDescriptors
in interface BeanInfo
public Properties toProperties(boolean storeDefaults)
toProperties
in interface Configuration
storeDefaults
- if false, then property values that are
equal to the default value for a
configuration will not be storedConfiguration.toProperties(boolean)
public void fromProperties(Properties props)
fromProperties
in interface Configuration
public Object clone()
Configuration
clone
in interface Configuration
clone
in class Object
protected boolean isInvalidProperty(String propName)
public void fromFile(File f) throws IOException
Configuration
fromFile
in interface Configuration
public void fromStream(InputStream in) throws IOException
Configuration
fromStream
in interface Configuration
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(boolean)
.equals
in class Object
public int hashCode()
toProperties(boolean)
.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(boolean)
.writeExternal
in interface Externalizable
protected Value addValue(Value val)
protected StringValue addString(String property)
protected FileValue addFile(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)
public Log getConfigurationLog()
com.solarmetric.Runtime
by
default.getConfigurationLog
in interface Configuration
public RuntimeException getConfigurationException(String msg, Throwable cause)
getConfigurationException
in interface Configuration
public boolean hasJava5()
Configuration
true
if this VM has Java 5 features; otherwise
returns false
.hasJava5
in interface Configuration
|
SolarMetric Kodo JDO 3.4.1 generated on May 30 2006 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |