Package org.apache.openjpa.lib.conf
Interface Configuration
-
- All Superinterfaces:
java.beans.BeanInfo
,java.lang.Cloneable
,Closeable
,java.io.Serializable
- All Known Subinterfaces:
DistributedConfiguration
,DistributedJDBCConfiguration
,JDBCConfiguration
,OpenJPAConfiguration
- All Known Implementing Classes:
ConfigurationImpl
,DistributedJDBCConfigurationImpl
,JDBCConfigurationImpl
,OpenJPAConfigurationImpl
,XMLConfiguration
public interface Configuration extends java.beans.BeanInfo, java.io.Serializable, Closeable, java.lang.Cloneable
Interface for generic configuration objects. Includes the ability to write configuration to and fromProperties
instances. Instances are threadsafe for reads, but not for writes.- Author:
- Marc Prud'hommeaux, Abe White
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
ATTRIBUTE_ALLOWED_VALUES
Attribute of returnedValue
property descriptors listing recognized values for the property.static java.lang.String
ATTRIBUTE_CATEGORY
Attribute of the returnedValue
property descriptors naming the property' hierarchical category.static java.lang.String
ATTRIBUTE_INTERFACE
Attribute of the returnedValue
property descriptors naming the interface that plugin values for this property must implement.static java.lang.String
ATTRIBUTE_ORDER
Attribute of the returnedValue
property descriptors naming the property's ordering in its category.static java.lang.String
ATTRIBUTE_TYPE
Attribute of the returnedValue
property descriptors naming the property's type or category.static java.lang.String
ATTRIBUTE_XML
Attribute of the returnedValue
property descriptors naming the property's name in XML format (i.e. two-words instead of TwoWords).static int
INIT_STATE_FREEZING
static int
INIT_STATE_FROZEN
static int
INIT_STATE_LIQUID
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a listener for any property changes.<T extends Value>
TaddValue(T val)
Add the given value to the set of configuration properties.java.lang.Object
clone()
Return a copy of this configuration.void
close()
Free the resources used by this object.void
fromProperties(java.util.Map map)
Set this Configuration via the given map.Log
getConfigurationLog()
Return the log to use for configuration messages.java.lang.String
getId()
An environment-specific identifier for this configuration.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.lang.String
getProductName()
Return the product name.java.util.Set<java.lang.String>
getPropertyKeys()
Get the set of all known property keys, including any equivalent keys, appropriately prefixed.java.util.List<java.lang.String>
getPropertyKeys(java.lang.String propertyName)
Get the set of all known property keys, including any equivalent keys, appropriately prefixed.java.lang.ClassLoader
getUserClassLoader()
Gets a class loader that can be additionally used to load custom plugin values.Value
getValue(java.lang.String property)
Return theValue
for the given property, or null if none.Value[]
getValues()
Return the set of allValue
s.void
instantiateAll()
Call the instantiating get methods for all values.boolean
isReadOnly()
Return true if this configuration is immutable.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
setId(java.lang.String id)
An environment-specific identifier for this configuration.void
setLog(java.lang.String log)
Log plugin setting.void
setLogFactory(LogFactory factory)
The log factory.void
setProductName(java.lang.String name)
Set the product name.void
setReadOnly(int readOnly)
Lock down the configuration's state.void
setUserClassLoader(java.lang.ClassLoader loader)
Sets an additional classloader to load custom plugin values.java.util.Map<java.lang.String,java.lang.Object>
toProperties(boolean storeDefaults)
A properties representation of this Configuration.
-
-
-
Field Detail
-
ATTRIBUTE_ALLOWED_VALUES
static final java.lang.String ATTRIBUTE_ALLOWED_VALUES
Attribute of returnedValue
property descriptors listing recognized values for the property.- See Also:
- Constant Field Values
-
ATTRIBUTE_TYPE
static final java.lang.String ATTRIBUTE_TYPE
Attribute of the returnedValue
property descriptors naming the property's type or category.- See Also:
- Constant Field Values
-
ATTRIBUTE_CATEGORY
static final java.lang.String ATTRIBUTE_CATEGORY
Attribute of the returnedValue
property descriptors naming the property' hierarchical category.- See Also:
- Constant Field Values
-
ATTRIBUTE_ORDER
static final java.lang.String ATTRIBUTE_ORDER
Attribute of the returnedValue
property descriptors naming the property's ordering in its category.- See Also:
- Constant Field Values
-
ATTRIBUTE_INTERFACE
static final java.lang.String ATTRIBUTE_INTERFACE
Attribute of the returnedValue
property descriptors naming the interface that plugin values for this property must implement.- See Also:
- Constant Field Values
-
ATTRIBUTE_XML
static final java.lang.String ATTRIBUTE_XML
Attribute of the returnedValue
property descriptors naming the property's name in XML format (i.e. two-words instead of TwoWords).- See Also:
- Constant Field Values
-
INIT_STATE_LIQUID
static final int INIT_STATE_LIQUID
- See Also:
- Constant Field Values
-
INIT_STATE_FREEZING
static final int INIT_STATE_FREEZING
- See Also:
- Constant Field Values
-
INIT_STATE_FROZEN
static final int INIT_STATE_FROZEN
- See Also:
- Constant Field Values
-
-
Method Detail
-
getProductName
java.lang.String getProductName()
Return the product name. Defaults toopenjpa
.
-
setProductName
void setProductName(java.lang.String name)
Set the product name.
-
getLogFactory
LogFactory getLogFactory()
The log factory. If no log factory has been set explicitly, this method will create one.
-
setLogFactory
void setLogFactory(LogFactory factory)
The log factory.
-
getLog
java.lang.String getLog()
Log plugin setting.
-
setLog
void setLog(java.lang.String log)
Log plugin setting.
-
getLog
Log getLog(java.lang.String category)
Return the log for the given category.- See Also:
getLogFactory()
-
getConfigurationLog
Log getConfigurationLog()
Return the log to use for configuration messages.
-
getId
java.lang.String getId()
An environment-specific identifier for this configuration. This might correspond to a JPA persistence-unit name, or to some other more-unique value available in the current environment.- Since:
- 0.9.7
-
setId
void setId(java.lang.String id)
An environment-specific identifier for this configuration. This might correspond to a JPA persistence-unit name, or to some other more-unique value available in the current environment.- Since:
- 0.9.7
-
getValue
Value getValue(java.lang.String property)
Return theValue
for the given property, or null if none.
-
addValue
<T extends Value> T addValue(T val)
Add the given value to the set of configuration properties. This method replaces any existing value under the same property.
-
removeValue
boolean removeValue(Value val)
Remove the given value from the set of configuration properties.
-
toProperties
java.util.Map<java.lang.String,java.lang.Object> toProperties(boolean storeDefaults)
A properties representation of this Configuration. Note that changes made to this properties object will not be automatically reflected in this Configuration object.- Parameters:
storeDefaults
- if true, then properties will be written out even if they match the default value for a property
-
getPropertyKeys
java.util.List<java.lang.String> getPropertyKeys(java.lang.String propertyName)
Get the set of all known property keys, including any equivalent keys, appropriately prefixed.- Parameters:
propertyName
- the name of the property for which the keys are to be retrieved.- Since:
- 2.0.0
-
getPropertyKeys
java.util.Set<java.lang.String> getPropertyKeys()
Get the set of all known property keys, including any equivalent keys, appropriately prefixed.- Since:
- 2.0.0
-
fromProperties
void fromProperties(java.util.Map map)
Set this Configuration via the given map. Any keys missing from the given map will not be set. Note that changes made to this map will not be automatically reflected in this Configuration object. IMPORTANT: If the map contains instantiated objects(rather than string values), only the string representation of those objects are considered in this configuration'sequals
andhashCode
methods. If the object's property has no string form(such as anObjectValue
), the object is not part of the equality and hashing calculations.
-
addPropertyChangeListener
void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a listener for any property changes. The property events fired will not include the old value.- Parameters:
listener
- the listener to receive notification of property changes
-
removePropertyChangeListener
void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a listener for any property changes.- Parameters:
listener
- the listener to remove
-
setReadOnly
void setReadOnly(int readOnly)
Lock down the configuration's state. Attempting to set state on a read-only configuration results in an exception.
-
isReadOnly
boolean isReadOnly()
Return true if this configuration is immutable.
-
instantiateAll
void instantiateAll()
Call the instantiating get methods for all values. Up-front instantiation allows one to avoid the synchronization necessary with lazy instantiation.
-
close
void close()
Free the resources used by this object.
-
clone
java.lang.Object clone()
Return a copy of this configuration.
-
getUserClassLoader
java.lang.ClassLoader getUserClassLoader()
Gets a class loader that can be additionally used to load custom plugin values.- Returns:
- an additional classloader for loading custom plugins. Can be null.
- Since:
- 2.3.0
- See Also:
Configurations.newInstance(String, ClassLoader)
-
setUserClassLoader
void setUserClassLoader(java.lang.ClassLoader loader)
Sets an additional classloader to load custom plugin values. In OSGi environment, we internally set the bundle class loader as the user class loader.- Parameters:
loader
- a class loader to load custom plugin values- Since:
- 2.3.0
-
-