Package org.apache.commons.configuration
Class JNDIConfiguration
java.lang.Object
org.apache.commons.configuration.event.EventSource
org.apache.commons.configuration.AbstractConfiguration
org.apache.commons.configuration.JNDIConfiguration
- All Implemented Interfaces:
Configuration
This Configuration class allows you to interface with a JNDI datasource.
A JNDIConfiguration is read-only, write operations will throw an
UnsupportedOperationException. The clear operations are supported but the
underlying JNDI data source is not changed.
- Version:
- $Id: JNDIConfiguration.java 1234985 2012-01-23 21:09:09Z oheger $
- Author:
- Eric Pugh
-
Field Summary
Fields inherited from class org.apache.commons.configuration.AbstractConfiguration
END_TOKEN, EVENT_ADD_PROPERTY, EVENT_CLEAR, EVENT_CLEAR_PROPERTY, EVENT_READ_PROPERTY, EVENT_SET_PROPERTY, START_TOKEN
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a JNDIConfiguration using the default initial context as the root of the properties.JNDIConfiguration
(String prefix) Creates a JNDIConfiguration using the default initial context, shifted with the specified prefix, as the root of the properties.JNDIConfiguration
(Context context) Creates a JNDIConfiguration using the specified initial context as the root of the properties.JNDIConfiguration
(Context context, String prefix) Creates a JNDIConfiguration using the specified initial context shifted by the specified prefix as the root of the properties. -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addPropertyDirect
(String key, Object obj) This operation is not supported and will throw an UnsupportedOperationException.void
clearProperty
(String key) Removes the specified property.boolean
containsKey
(String key) Checks whether the specified key is contained in this configuration.Return the base context with the prefix applied.Return the initial context used by this configuration.getKeys()
Returns an iterator with all property keys stored in this configuration.Returns an iterator with all property keys starting with the given prefix.Returns the prefix.getProperty
(String key) Returns the value of the specified property.boolean
isEmpty()
Returns a flag whether this configuration is empty.void
setContext
(Context context) Set the initial context of the configuration.void
Sets the prefix.void
setProperty
(String key, Object value) This operation is not supported and will throw an UnsupportedOperationException.Methods inherited from class org.apache.commons.configuration.AbstractConfiguration
addErrorLogListener, addProperty, append, clear, clearPropertyDirect, copy, createInterpolator, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDefaultListDelimiter, getDelimiter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getList, getList, getListDelimiter, getLogger, getLong, getLong, getLong, getProperties, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, getSubstitutor, interpolate, interpolate, interpolatedConfiguration, interpolateHelper, isDelimiterParsingDisabled, isScalarValue, isThrowExceptionOnMissing, resolveContainerStore, setDefaultListDelimiter, setDelimiter, setDelimiterParsingDisabled, setListDelimiter, setLogger, setThrowExceptionOnMissing, subset
Methods inherited from class org.apache.commons.configuration.event.EventSource
addConfigurationListener, addErrorListener, clearConfigurationListeners, clearErrorListeners, clone, createErrorEvent, createEvent, fireError, fireEvent, getConfigurationListeners, getErrorListeners, isDetailEvents, removeConfigurationListener, removeErrorListener, setDetailEvents
-
Constructor Details
-
JNDIConfiguration
Creates a JNDIConfiguration using the default initial context as the root of the properties.- Throws:
NamingException
- thrown if an error occurs when initializing the default context
-
JNDIConfiguration
Creates a JNDIConfiguration using the default initial context, shifted with the specified prefix, as the root of the properties.- Parameters:
prefix
- the prefix- Throws:
NamingException
- thrown if an error occurs when initializing the default context
-
JNDIConfiguration
Creates a JNDIConfiguration using the specified initial context as the root of the properties.- Parameters:
context
- the initial context
-
JNDIConfiguration
Creates a JNDIConfiguration using the specified initial context shifted by the specified prefix as the root of the properties.- Parameters:
context
- the initial contextprefix
- the prefix
-
-
Method Details
-
getKeys
Returns an iterator with all property keys stored in this configuration.- Returns:
- an iterator with all keys
-
getKeys
Returns an iterator with all property keys starting with the given prefix.- Specified by:
getKeys
in interfaceConfiguration
- Overrides:
getKeys
in classAbstractConfiguration
- Parameters:
prefix
- the prefix- Returns:
- an iterator with the selected keys
- See Also:
-
isEmpty
Returns a flag whether this configuration is empty.- Returns:
- the empty flag
-
setProperty
This operation is not supported and will throw an UnsupportedOperationException.
- Specified by:
setProperty
in interfaceConfiguration
- Overrides:
setProperty
in classAbstractConfiguration
- Parameters:
key
- the keyvalue
- the value- Throws:
UnsupportedOperationException
-
clearProperty
Removes the specified property.- Specified by:
clearProperty
in interfaceConfiguration
- Overrides:
clearProperty
in classAbstractConfiguration
- Parameters:
key
- the key of the property to remove
-
containsKey
Checks whether the specified key is contained in this configuration.- Parameters:
key
- the key to check- Returns:
- a flag whether this key is stored in this configuration
-
getPrefix
Returns the prefix.- Returns:
- the prefix
-
setPrefix
Sets the prefix.- Parameters:
prefix
- The prefix to set
-
getProperty
Returns the value of the specified property.- Parameters:
key
- the key of the property- Returns:
- the value of this property
-
addPropertyDirect
This operation is not supported and will throw an UnsupportedOperationException.
- Specified by:
addPropertyDirect
in classAbstractConfiguration
- Parameters:
key
- the keyobj
- the value- Throws:
UnsupportedOperationException
-
getBaseContext
Return the base context with the prefix applied.- Returns:
- the base context
- Throws:
NamingException
- if an error occurs
-
getContext
Return the initial context used by this configuration. This context is independent of the prefix specified.- Returns:
- the initial context
-
setContext
Set the initial context of the configuration.- Parameters:
context
- the context
-