|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.openjpa.lib.conf.ConfigurationImpl
public class 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.
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 | |
---|---|
ObjectValue |
logFactoryPlugin
|
Fields inherited from interface org.apache.openjpa.lib.conf.Configuration |
---|
ATTRIBUTE_ALLOWED_VALUES, ATTRIBUTE_CATEGORY, ATTRIBUTE_INTERFACE, ATTRIBUTE_ORDER, ATTRIBUTE_TYPE, ATTRIBUTE_XML |
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 | |
---|---|
BooleanValue |
addBoolean(java.lang.String property)
Add the given value to the set of configuration properties. |
DoubleValue |
addDouble(java.lang.String property)
Add the given value to the set of configuration properties. |
FileValue |
addFile(java.lang.String property)
Add the given value to the set of configuration properties. |
IntValue |
addInt(java.lang.String property)
Add the given value to the set of configuration properties. |
ObjectValue |
addObject(java.lang.String property)
Add the given value to the set of configuration properties. |
PluginValue |
addPlugin(java.lang.String property,
boolean singleton)
Add the given value to the set of configuration properties. |
PluginListValue |
addPluginList(java.lang.String property)
Add the given value to the set of configuration properties. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a listener for any property changes. |
void |
addPropertyPrefix(java.lang.String prefix)
Add prefix to the list of prefixes to use
to identify valid configuration properties. |
StringValue |
addString(java.lang.String property)
Add the given value to the set of configuration properties. |
StringListValue |
addStringList(java.lang.String property)
Add the given value to the set of configuration properties. |
Value |
addValue(Value val)
Add the given value to the set of configuration properties. |
void |
assertNotReadOnly()
Checks if the configuration is read only and if so throws an exception, otherwise returns silently. |
java.lang.Object |
clone()
Uses toProperties(boolean) and fromProperties(java.util.Map) to clone
configuration. |
void |
close()
Closes all closeable values and plugins. |
boolean |
equals(java.lang.Object other)
Performs an equality check based on the properties returned from toProperties(boolean) . |
void |
fromProperties(java.util.Map map)
Set this Configuration via the given map. |
java.beans.BeanInfo[] |
getAdditionalBeanInfo()
|
java.beans.BeanDescriptor |
getBeanDescriptor()
|
Log |
getConfigurationLog()
Returns the logging channel openjpa.Runtime by default. |
int |
getDefaultEventIndex()
|
int |
getDefaultPropertyIndex()
|
java.beans.EventSetDescriptor[] |
getEventSetDescriptors()
|
java.awt.Image |
getIcon(int kind)
|
java.lang.String |
getLog()
Log plugin setting. |
Log |
getLog(java.lang.String category)
Return the log for the given category. |
LogFactory |
getLogFactory()
The log factory. |
java.beans.MethodDescriptor[] |
getMethodDescriptors()
|
java.lang.String |
getProductName()
Return the product name. |
java.beans.PropertyDescriptor[] |
getPropertyDescriptors()
|
Value |
getValue(java.lang.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) . |
void |
instantiateAll()
Call the instantiating get methods for all values. |
protected boolean |
isInvalidProperty(java.lang.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 |
isReadOnly()
Return true if this configuration is immutable. |
boolean |
loadDefaults()
Automatically load default values from the system's ConfigurationProvider s, and from System properties. |
void |
readExternal(java.io.ObjectInput in)
Implementation of the Externalizable interface to read from
the properties written by writeExternal(java.io.ObjectOutput) . |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a listener for any property changes. |
boolean |
removeValue(Value val)
Remove the given value from the set of configuration properties. |
void |
setLog(java.lang.String log)
Log plugin setting. |
void |
setLogFactory(LogFactory logFactory)
The log factory. |
void |
setProductName(java.lang.String name)
Set the product name. |
void |
setProperties(java.lang.String resourceName)
This method loads the named resource as a properties file. |
void |
setPropertiesFile(java.io.File file)
This method loads the named file as a properties file. |
void |
setReadOnly(boolean readOnly)
Lock down the configuration's state. |
java.util.Map |
toProperties(boolean storeDefaults)
A properties representation of this Configuration. |
static java.lang.String |
toXMLName(java.lang.String propName)
Convert propName to a lowercase-with-hyphens-style string. |
void |
valueChanged(Value val)
Callback used by Value objects to notify listener of change. |
void |
writeExternal(java.io.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 |
---|
public ObjectValue logFactoryPlugin
Constructor Detail |
---|
public ConfigurationImpl()
ConfigurationProvider
s.
public ConfigurationImpl(boolean loadDefaults)
loadDefaults
- whether to attempt to load the default propertiesMethod Detail |
---|
public boolean loadDefaults()
ConfigurationProvider
s, and from System properties.
public java.lang.String getProductName()
Configuration
openjpa
.
getProductName
in interface Configuration
public void setProductName(java.lang.String name)
Configuration
setProductName
in interface Configuration
public LogFactory getLogFactory()
Configuration
getLogFactory
in interface Configuration
public void setLogFactory(LogFactory logFactory)
Configuration
setLogFactory
in interface Configuration
public java.lang.String getLog()
Configuration
getLog
in interface Configuration
public void setLog(java.lang.String log)
Configuration
setLog
in interface Configuration
public Log getLog(java.lang.String category)
Configuration
getLog
in interface Configuration
Configuration.getLogFactory()
public Log getConfigurationLog()
openjpa.Runtime
by default.
getConfigurationLog
in interface Configuration
public Value[] getValues()
Configuration
Value
s.
getValues
in interface Configuration
public Value getValue(java.lang.String property)
Configuration
Value
for the given property, or null if none.
getValue
in interface Configuration
public void setReadOnly(boolean readOnly)
Configuration
setReadOnly
in interface Configuration
public void instantiateAll()
Configuration
instantiateAll
in interface Configuration
public boolean isReadOnly()
Configuration
isReadOnly
in interface Configuration
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Configuration
addPropertyChangeListener
in interface Configuration
listener
- the listener to receive notification of property changespublic void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Configuration
removePropertyChangeListener
in interface 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()
close
in interface Configuration
close
in interface Closeable
public java.beans.BeanInfo[] getAdditionalBeanInfo()
getAdditionalBeanInfo
in interface java.beans.BeanInfo
public java.beans.BeanDescriptor getBeanDescriptor()
getBeanDescriptor
in interface java.beans.BeanInfo
public int getDefaultEventIndex()
getDefaultEventIndex
in interface java.beans.BeanInfo
public int getDefaultPropertyIndex()
getDefaultPropertyIndex
in interface java.beans.BeanInfo
public java.beans.EventSetDescriptor[] getEventSetDescriptors()
getEventSetDescriptors
in interface java.beans.BeanInfo
public java.awt.Image getIcon(int kind)
getIcon
in interface java.beans.BeanInfo
public java.beans.MethodDescriptor[] getMethodDescriptors()
getMethodDescriptors
in interface java.beans.BeanInfo
public java.beans.PropertyDescriptor[] getPropertyDescriptors()
getPropertyDescriptors
in interface java.beans.BeanInfo
public void addPropertyPrefix(java.lang.String prefix)
Configuration
prefix
to the list of prefixes to use
to identify valid configuration properties. "openjpa" and any
product name set with Configuration.setProductName(java.lang.String)
will automatically
be added.
addPropertyPrefix
in interface Configuration
public java.util.Map toProperties(boolean storeDefaults)
Configuration
toProperties
in interface Configuration
storeDefaults
- if true, then properties will be written
out even if they match the default value for a propertypublic void fromProperties(java.util.Map map)
Configuration
equals
and
hashCode
methods. If the object's property has no
string form(such as an ObjectValue
), the object is not
part of the equality and hashing calculations.
fromProperties
in interface Configuration
protected boolean isInvalidProperty(java.lang.String propName)
public void setProperties(java.lang.String resourceName) throws java.io.IOException
properties
value with the name of a resource.
java.io.IOException
public void setPropertiesFile(java.io.File file) throws java.io.IOException
propertiesFile
value with the name of a file.
java.io.IOException
public void assertNotReadOnly()
public boolean equals(java.lang.Object other)
toProperties(boolean)
.
equals
in class java.lang.Object
public int hashCode()
toProperties(boolean)
.
hashCode
in class java.lang.Object
public static java.lang.String toXMLName(java.lang.String propName)
propName
to a lowercase-with-hyphens-style string.
This algorithm is only designed for mixes of uppercase and lowercase
letters and lone digits. A more sophisticated conversion should probably
be handled by a proper parser generator or regular expressions.
public void readExternal(java.io.ObjectInput in) throws java.io.IOException, java.lang.ClassNotFoundException
Externalizable
interface to read from
the properties written by writeExternal(java.io.ObjectOutput)
.
readExternal
in interface java.io.Externalizable
java.io.IOException
java.lang.ClassNotFoundException
public void writeExternal(java.io.ObjectOutput out) throws java.io.IOException
Externalizable
interface to write
the properties returned by toProperties(boolean)
.
writeExternal
in interface java.io.Externalizable
java.io.IOException
public java.lang.Object clone()
toProperties(boolean)
and fromProperties(java.util.Map)
to clone
configuration.
clone
in interface Configuration
clone
in class java.lang.Object
public boolean removeValue(Value val)
Configuration
removeValue
in interface Configuration
public Value addValue(Value val)
Configuration
addValue
in interface Configuration
public StringValue addString(java.lang.String property)
public FileValue addFile(java.lang.String property)
public IntValue addInt(java.lang.String property)
public DoubleValue addDouble(java.lang.String property)
public BooleanValue addBoolean(java.lang.String property)
public StringListValue addStringList(java.lang.String property)
public ObjectValue addObject(java.lang.String property)
public PluginValue addPlugin(java.lang.String property, boolean singleton)
public PluginListValue addPluginList(java.lang.String property)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |