Class JNDIConfiguration
- java.lang.Object
-
- org.apache.commons.configuration2.event.BaseEventSource
-
- org.apache.commons.configuration2.AbstractConfiguration
-
- org.apache.commons.configuration2.JNDIConfiguration
-
- All Implemented Interfaces:
Configuration,EventSource,ImmutableConfiguration,SynchronizerSupport
public class JNDIConfiguration extends AbstractConfiguration
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.
-
-
Constructor Summary
Constructors Constructor Description JNDIConfiguration()Creates a JNDIConfiguration using the default initial context as the root of the properties.JNDIConfiguration(java.lang.String prefix)Creates a JNDIConfiguration using the default initial context, shifted with the specified prefix, as the root of the properties.JNDIConfiguration(javax.naming.Context context)Creates a JNDIConfiguration using the specified initial context as the root of the properties.JNDIConfiguration(javax.naming.Context context, java.lang.String prefix)Creates a JNDIConfiguration using the specified initial context shifted by the specified prefix as the root of the properties.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddPropertyDirect(java.lang.String key, java.lang.Object obj)This operation is not supported and will throw an UnsupportedOperationException.protected voidclearPropertyDirect(java.lang.String key)Removes the specified property.protected booleancontainsKeyInternal(java.lang.String key)Checks whether the specified key is contained in this configuration.protected booleancontainsValueInternal(java.lang.Object value)Tests whether this configuration contains one or more matches to this value.javax.naming.ContextgetBaseContext()Gets the base context with the prefix applied.javax.naming.ContextgetContext()Gets the initial context used by this configuration.protected java.util.Iterator<java.lang.String>getKeysInternal()Gets an iterator with all property keys stored in this configuration.protected java.util.Iterator<java.lang.String>getKeysInternal(java.lang.String prefix)Gets an iterator with all property keys starting with the given prefix.java.lang.StringgetPrefix()Gets the prefix.protected java.lang.ObjectgetPropertyInternal(java.lang.String key)Gets the value of the specified property.protected booleanisEmptyInternal()Returns a flag whether this configuration is empty.voidsetContext(javax.naming.Context context)Sets the initial context of the configuration.voidsetPrefix(java.lang.String prefix)Sets the prefix.protected voidsetPropertyInternal(java.lang.String key, java.lang.Object value)This operation is not supported and will throw an UnsupportedOperationException.-
Methods inherited from class org.apache.commons.configuration2.AbstractConfiguration
addErrorLogListener, addProperty, addPropertyInternal, append, beginRead, beginWrite, clear, clearInternal, clearProperty, cloneInterpolator, contains, containsKey, containsValue, copy, endRead, endWrite, get, get, getArray, getArray, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getCollection, getCollection, getConfigurationDecoder, getConversionHandler, getDouble, getDouble, getDouble, getDuration, getDuration, getEncodedString, getEncodedString, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getInterpolator, getKeys, getKeys, getKeys, getKeysInternal, getList, getList, getList, getList, getListDelimiterHandler, getLogger, getLong, getLong, getLong, getProperties, getProperties, getProperty, getShort, getShort, getShort, getString, getString, getStringArray, getSynchronizer, immutableSubset, initLogger, installInterpolator, interpolate, interpolate, interpolatedConfiguration, isEmpty, isScalarValue, isThrowExceptionOnMissing, lock, setConfigurationDecoder, setConversionHandler, setDefaultLookups, setInterpolator, setListDelimiterHandler, setLogger, setParentInterpolator, setPrefixLookups, setProperty, setSynchronizer, setThrowExceptionOnMissing, size, sizeInternal, subset, unlock
-
Methods inherited from class org.apache.commons.configuration2.event.BaseEventSource
addEventListener, clearErrorListeners, clearEventListeners, clone, copyEventListeners, createErrorEvent, createEvent, fireError, fireEvent, getEventListenerRegistrations, getEventListeners, isDetailEvents, removeEventListener, setDetailEvents
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.commons.configuration2.ImmutableConfiguration
entrySet, forEach, getEnum, getEnum
-
-
-
-
Constructor Detail
-
JNDIConfiguration
public JNDIConfiguration() throws javax.naming.NamingExceptionCreates a JNDIConfiguration using the default initial context as the root of the properties.- Throws:
javax.naming.NamingException- thrown if an error occurs when initializing the default context
-
JNDIConfiguration
public JNDIConfiguration(javax.naming.Context context)
Creates a JNDIConfiguration using the specified initial context as the root of the properties.- Parameters:
context- the initial context
-
JNDIConfiguration
public JNDIConfiguration(javax.naming.Context context, java.lang.String prefix)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
-
JNDIConfiguration
public JNDIConfiguration(java.lang.String prefix) throws javax.naming.NamingExceptionCreates a JNDIConfiguration using the default initial context, shifted with the specified prefix, as the root of the properties.- Parameters:
prefix- the prefix- Throws:
javax.naming.NamingException- thrown if an error occurs when initializing the default context
-
-
Method Detail
-
addPropertyDirect
protected void addPropertyDirect(java.lang.String key, java.lang.Object obj)This operation is not supported and will throw an UnsupportedOperationException.
- Specified by:
addPropertyDirectin classAbstractConfiguration- Parameters:
key- the keyobj- the value- Throws:
java.lang.UnsupportedOperationException- always thrown as this method is not supported
-
clearPropertyDirect
protected void clearPropertyDirect(java.lang.String key)
Removes the specified property.- Specified by:
clearPropertyDirectin classAbstractConfiguration- Parameters:
key- the key of the property to remove
-
containsKeyInternal
protected boolean containsKeyInternal(java.lang.String key)
Checks whether the specified key is contained in this configuration.- Specified by:
containsKeyInternalin classAbstractConfiguration- Parameters:
key- the key to check- Returns:
- a flag whether this key is stored in this configuration
-
containsValueInternal
protected boolean containsValueInternal(java.lang.Object value)
Tests whether this configuration contains one or more matches to this value. This operation stops at first match but may be more expensive than the containsKey method.- Specified by:
containsValueInternalin classAbstractConfiguration- Parameters:
value- the value in question- Returns:
trueif and only if some key maps to thevalueargument in this configuration as determined by theequalsmethod;falseotherwise.- Since:
- 2.11.0
-
getBaseContext
public javax.naming.Context getBaseContext() throws javax.naming.NamingExceptionGets the base context with the prefix applied.- Returns:
- the base context
- Throws:
javax.naming.NamingException- if an error occurs
-
getContext
public javax.naming.Context getContext()
Gets the initial context used by this configuration. This context is independent of the prefix specified.- Returns:
- the initial context
-
getKeysInternal
protected java.util.Iterator<java.lang.String> getKeysInternal()
Gets an iterator with all property keys stored in this configuration.- Specified by:
getKeysInternalin classAbstractConfiguration- Returns:
- an iterator with all keys
-
getKeysInternal
protected java.util.Iterator<java.lang.String> getKeysInternal(java.lang.String prefix)
Gets an iterator with all property keys starting with the given prefix.- Overrides:
getKeysInternalin classAbstractConfiguration- Parameters:
prefix- the prefix- Returns:
- an iterator with the selected keys
-
getPrefix
public java.lang.String getPrefix()
Gets the prefix.- Returns:
- the prefix
-
getPropertyInternal
protected java.lang.Object getPropertyInternal(java.lang.String key)
Gets the value of the specified property.- Specified by:
getPropertyInternalin classAbstractConfiguration- Parameters:
key- the key of the property- Returns:
- the value of this property
-
isEmptyInternal
protected boolean isEmptyInternal()
Returns a flag whether this configuration is empty.- Specified by:
isEmptyInternalin classAbstractConfiguration- Returns:
- the empty flag
-
setContext
public void setContext(javax.naming.Context context)
Sets the initial context of the configuration.- Parameters:
context- the context
-
setPrefix
public void setPrefix(java.lang.String prefix)
Sets the prefix.- Parameters:
prefix- The prefix to set
-
setPropertyInternal
protected void setPropertyInternal(java.lang.String key, java.lang.Object value)This operation is not supported and will throw an UnsupportedOperationException.
- Overrides:
setPropertyInternalin classAbstractConfiguration- Parameters:
key- the keyvalue- the value- Throws:
java.lang.UnsupportedOperationException- always thrown as this method is not supported
-
-