public class ConfigurationImpl extends Object implements Configuration, Externalizable, ValueListener
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:
| Modifier and Type | Field and Description |
|---|---|
StringValue |
id |
ObjectValue |
logFactoryPlugin |
ATTRIBUTE_ALLOWED_VALUES, ATTRIBUTE_CATEGORY, ATTRIBUTE_INTERFACE, ATTRIBUTE_ORDER, ATTRIBUTE_TYPE, ATTRIBUTE_XML, INIT_STATE_FREEZING, INIT_STATE_FROZEN, INIT_STATE_LIQUIDICON_COLOR_16x16, ICON_COLOR_32x32, ICON_MONO_16x16, ICON_MONO_32x32| Constructor and Description |
|---|
ConfigurationImpl()
Default constructor.
|
ConfigurationImpl(boolean loadGlobals)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
BooleanValue |
addBoolean(String property)
Add the given value to the set of configuration properties.
|
DoubleValue |
addDouble(String property)
Add the given value to the set of configuration properties.
|
FileValue |
addFile(String property)
Add the given value to the set of configuration properties.
|
IntValue |
addInt(String property)
Add the given value to the set of configuration properties.
|
ObjectValue |
addObject(String property)
Add the given value to the set of configuration properties.
|
PluginValue |
addPlugin(String property,
boolean singleton)
Add the given value to the set of configuration properties.
|
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.
|
StringValue |
addString(String property)
Add the given value to the set of configuration properties.
|
StringListValue |
addStringList(String property)
Add the given value to the set of configuration properties.
|
<T extends Value> |
addValue(T val)
Add the given value to the set of configuration properties.
|
Object |
clone()
Uses
toProperties(boolean) and fromProperties(java.util.Map) to clone
configuration. |
void |
close()
Closes all closeable values and plugins.
|
boolean |
equals(Object other)
Performs an equality check based on equality of values.
|
void |
fromProperties(Map map)
Set this Configuration via the given map.
|
BeanInfo[] |
getAdditionalBeanInfo() |
BeanDescriptor |
getBeanDescriptor() |
Log |
getConfigurationLog()
Returns the logging channel
openjpa.Runtime by default. |
int |
getDefaultEventIndex() |
int |
getDefaultPropertyIndex() |
EventSetDescriptor[] |
getEventSetDescriptors() |
Image |
getIcon(int kind) |
String |
getId()
An environment-specific identifier for this configuration.
|
String |
getLog()
Log plugin setting.
|
Log |
getLog(String category)
Return the log for the given category.
|
LogFactory |
getLogFactory()
The log factory.
|
MethodDescriptor[] |
getMethodDescriptors() |
String |
getProductName()
Return the product name.
|
String |
getPropertiesResource()
Return the resource that was set via auto-configuration methods
setProperties(java.lang.String) or setPropertiesFile(java.io.File), or null if none. |
PropertyDescriptor[] |
getPropertyDescriptors() |
Set<String> |
getPropertyKeys()
Gets all known property keys.
|
List<String> |
getPropertyKeys(String propertyName)
Get the set of all known property keys, including any equivalent keys,
appropriately prefixed.
|
ClassLoader |
getUserClassLoader()
Gets a class loader that can be additionally used to load custom plugin values.
|
Value |
getValue(String property)
Gets the registered Value for the given propertyName.
|
Value[] |
getValues()
Return the set of all
Values. |
int |
hashCode()
Computes hash code based on the hashCodes of the values.
|
void |
instantiateAll()
Call the instantiating get methods for all values.
|
boolean |
isDeferResourceLoading() |
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 |
isReadOnly()
Return true if this configuration is immutable.
|
boolean |
loadGlobals()
Automatically load global values from the system's
ProductDerivations, and from System properties. |
protected void |
preClose()
Invoked by final method
close() after invoking the
ProductDerivation.beforeConfigurationClose(org.apache.openjpa.lib.conf.Configuration) callbacks
but before performing internal close operations. |
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.
|
boolean |
removeValue(Value val)
Remove the given value from the set of configuration properties.
|
void |
setDeferResourceLoading(boolean deferResourceLoading) |
void |
setId(String id)
An environment-specific identifier for this configuration.
|
void |
setLog(String log)
Log plugin setting.
|
void |
setLogFactory(LogFactory logFactory)
The log factory.
|
void |
setProductName(String name)
Set the product name.
|
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.
|
void |
setReadOnly(int newState)
Lock down the configuration's state.
|
void |
setUserClassLoader(ClassLoader cl)
Sets an additional classloader to load custom plugin values.
|
Map |
toProperties(boolean storeDefaults)
An internal method to retrieve properties, to support 2 public methods,
getAllProperties() and toProperties(boolean).
|
static String |
toXMLName(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(ObjectOutput out)
Implementation of the
Externalizable interface to write
the properties returned by toProperties(boolean). |
public ObjectValue logFactoryPlugin
public StringValue id
public ConfigurationImpl()
ProductDerivations.public ConfigurationImpl(boolean loadGlobals)
loadGlobals - whether to attempt to load the global propertiespublic boolean loadGlobals()
ProductDerivations, and from System properties.public String getProductName()
Configurationopenjpa.getProductName in interface Configurationpublic void setProductName(String name)
ConfigurationsetProductName in interface Configurationpublic LogFactory getLogFactory()
ConfigurationgetLogFactory in interface Configurationpublic void setLogFactory(LogFactory logFactory)
ConfigurationsetLogFactory in interface Configurationpublic String getLog()
ConfigurationgetLog in interface Configurationpublic void setLog(String log)
ConfigurationsetLog in interface Configurationpublic Log getLog(String category)
ConfigurationgetLog in interface ConfigurationConfiguration.getLogFactory()public String getId()
ConfigurationgetId in interface Configurationpublic void setId(String id)
ConfigurationsetId in interface Configurationpublic Log getConfigurationLog()
openjpa.Runtime by default.getConfigurationLog in interface Configurationpublic Value[] getValues()
ConfigurationValues.getValues in interface Configurationpublic Value getValue(String property)
getValue in interface Configurationproperty - can be either fully-qualified name or the simple name
with which the value has been registered. A value may have multiple
equivalent names and this method searches with all equivalent names.public void setReadOnly(int newState)
ConfigurationsetReadOnly in interface Configurationpublic boolean isDeferResourceLoading()
public void setDeferResourceLoading(boolean deferResourceLoading)
public void instantiateAll()
ConfigurationinstantiateAll in interface Configurationpublic boolean isReadOnly()
ConfigurationisReadOnly in interface Configurationpublic void addPropertyChangeListener(PropertyChangeListener listener)
ConfigurationaddPropertyChangeListener in interface Configurationlistener - the listener to receive notification of property changespublic void removePropertyChangeListener(PropertyChangeListener listener)
ConfigurationremovePropertyChangeListener in interface Configurationlistener - the listener to removepublic void valueChanged(Value val)
ValueListenerValue objects to notify listener of change.valueChanged in interface ValueListenerpublic final void close()
close in interface Configurationclose in interface Closeableprotected void preClose()
close() after invoking the
ProductDerivation.beforeConfigurationClose(org.apache.openjpa.lib.conf.Configuration) callbacks
but before performing internal close operations.public 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 MethodDescriptor[] getMethodDescriptors()
getMethodDescriptors in interface BeanInfopublic PropertyDescriptor[] getPropertyDescriptors()
getPropertyDescriptors in interface BeanInfopublic Map toProperties(boolean storeDefaults)
toProperties in interface ConfigurationstoreDefaults - whether or not to retrieve a property if its value is the
default value.public void fromProperties(Map map)
Configurationequals 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 Configurationpublic List<String> getPropertyKeys(String propertyName)
ConfigurationgetPropertyKeys in interface ConfigurationpropertyName - the name of the property for which the keys are
to be retrieved.public Set<String> getPropertyKeys()
getPropertyKeys in interface ConfigurationThe Values that are {@linkplain Value#makePrivate() marked private} are filtered out.protected boolean isInvalidProperty(String propName)
public void setProperties(String resourceName) throws IOException
properties value with the name of a resource.IOExceptionpublic void setPropertiesFile(File file) throws IOException
propertiesFile value with the name of a file.IOExceptionpublic String getPropertiesResource()
setProperties(java.lang.String) or setPropertiesFile(java.io.File), or null if none.public boolean equals(Object other)
public int hashCode()
public static String toXMLName(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(ObjectInput in) throws IOException, ClassNotFoundException
Externalizable interface to read from
the properties written by writeExternal(java.io.ObjectOutput).readExternal in interface ExternalizableIOExceptionClassNotFoundExceptionpublic void writeExternal(ObjectOutput out) throws IOException
Externalizable interface to write
the properties returned by toProperties(boolean).writeExternal in interface ExternalizableIOExceptionpublic Object clone()
toProperties(boolean) and fromProperties(java.util.Map) to clone
configuration.clone in interface Configurationclone in class Objectpublic boolean removeValue(Value val)
ConfigurationremoveValue in interface Configurationpublic <T extends Value> T addValue(T val)
ConfigurationaddValue in interface Configurationpublic StringValue addString(String property)
public FileValue addFile(String property)
public IntValue addInt(String property)
public DoubleValue addDouble(String property)
public BooleanValue addBoolean(String property)
public StringListValue addStringList(String property)
public ObjectValue addObject(String property)
public PluginValue addPlugin(String property, boolean singleton)
public PluginListValue addPluginList(String property)
public ClassLoader getUserClassLoader()
ConfigurationgetUserClassLoader in interface ConfigurationConfigurations.newInstance(String, ClassLoader)public void setUserClassLoader(ClassLoader cl)
ConfigurationsetUserClassLoader in interface Configurationcl - a class loader to load custom plugin valuesPersistenceProviderImpl.createEntityManagerFactory(String, Map)Copyright © 2006–2018 Apache Software Foundation. All rights reserved.