|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.configuration.event.EventSource
org.apache.commons.configuration.AbstractConfiguration
org.apache.commons.configuration.JNDIConfiguration
public class JNDIConfiguration
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.
Field Summary | |
---|---|
private javax.naming.Context |
baseContext
The base JNDI context. |
private java.util.Set |
clearedProperties
The Set of keys that have been virtually cleared. |
private javax.naming.Context |
context
The initial JNDI context. |
private java.lang.String |
prefix
The prefix of the context. |
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 | |
---|---|
JNDIConfiguration()
Creates a JNDIConfiguration using the default initial context 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. |
|
JNDIConfiguration(java.lang.String prefix)
Creates a JNDIConfiguration using the default initial context, shifted with the specified prefix, as the root of the properties. |
Method Summary | |
---|---|
protected void |
addPropertyDirect(java.lang.String key,
java.lang.Object obj)
This operation is not supported and will throw an UnsupportedOperationException. |
void |
clearProperty(java.lang.String key)
Removes the specified property. |
boolean |
containsKey(java.lang.String key)
Checks whether the specified key is contained in this configuration. |
javax.naming.Context |
getBaseContext()
Return the base context with the prefix applied. |
javax.naming.Context |
getContext()
Return the initial context used by this configuration. |
private javax.naming.Context |
getContext(java.util.List path,
javax.naming.Context context)
Because JNDI is based on a tree configuration, we need to filter down the tree, till we find the Context specified by the key to start from. |
java.util.Iterator |
getKeys()
Returns an iterator with all property keys stored in this configuration. |
java.util.Iterator |
getKeys(java.lang.String prefix)
Returns an iterator with all property keys starting with the given prefix. |
java.lang.String |
getPrefix()
Returns the prefix. |
java.lang.Object |
getProperty(java.lang.String key)
Returns the value of the specified property. |
boolean |
isEmpty()
Returns a flag whether this configuration is empty. |
private void |
recursiveGetKeys(java.util.Set keys,
javax.naming.Context context,
java.lang.String prefix)
This method recursive traverse the JNDI tree, looking for Context objects. |
void |
setContext(javax.naming.Context context)
Set the initial context of the configuration. |
void |
setPrefix(java.lang.String prefix)
Sets the prefix. |
void |
setProperty(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.configuration.event.EventSource |
---|
addConfigurationListener, addErrorListener, clearConfigurationListeners, clearErrorListeners, clone, createErrorEvent, createEvent, fireError, fireEvent, getConfigurationListeners, getErrorListeners, isDetailEvents, removeConfigurationListener, removeErrorListener, setDetailEvents |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.lang.String prefix
private javax.naming.Context context
private javax.naming.Context baseContext
private java.util.Set clearedProperties
Constructor Detail |
---|
public JNDIConfiguration() throws javax.naming.NamingException
javax.naming.NamingException
- thrown if an error occurs when initializing the default contextpublic JNDIConfiguration(java.lang.String prefix) throws javax.naming.NamingException
prefix
- the prefix
javax.naming.NamingException
- thrown if an error occurs when initializing the default contextpublic JNDIConfiguration(javax.naming.Context context)
context
- the initial contextpublic JNDIConfiguration(javax.naming.Context context, java.lang.String prefix)
context
- the initial contextprefix
- the prefixMethod Detail |
---|
private void recursiveGetKeys(java.util.Set keys, javax.naming.Context context, java.lang.String prefix) throws javax.naming.NamingException
keys
- All the keys that have been found.context
- The parent contextprefix
- What prefix we are building on.
javax.naming.NamingException
- If JNDI has an issue.public java.util.Iterator getKeys()
getKeys
in interface Configuration
getKeys
in class AbstractConfiguration
public java.util.Iterator getKeys(java.lang.String prefix)
getKeys
in interface Configuration
getKeys
in class AbstractConfiguration
prefix
- the prefix
Configuration.getKeys()
private javax.naming.Context getContext(java.util.List path, javax.naming.Context context) throws javax.naming.NamingException
path
- the path of keys to traverse in order to find the contextcontext
- the context to start from
javax.naming.NamingException
- if JNDI has an issuepublic boolean isEmpty()
isEmpty
in interface Configuration
isEmpty
in class AbstractConfiguration
public void setProperty(java.lang.String key, java.lang.Object value)
This operation is not supported and will throw an UnsupportedOperationException.
setProperty
in interface Configuration
setProperty
in class AbstractConfiguration
key
- the keyvalue
- the value
java.lang.UnsupportedOperationException
public void clearProperty(java.lang.String key)
clearProperty
in interface Configuration
clearProperty
in class AbstractConfiguration
key
- the key of the property to removepublic boolean containsKey(java.lang.String key)
containsKey
in interface Configuration
containsKey
in class AbstractConfiguration
key
- the key to check
public java.lang.String getPrefix()
public void setPrefix(java.lang.String prefix)
prefix
- The prefix to setpublic java.lang.Object getProperty(java.lang.String key)
key
- the key of the property
protected void addPropertyDirect(java.lang.String key, java.lang.Object obj)
This operation is not supported and will throw an UnsupportedOperationException.
addPropertyDirect
in class AbstractConfiguration
key
- the keyobj
- the value
java.lang.UnsupportedOperationException
public javax.naming.Context getBaseContext() throws javax.naming.NamingException
javax.naming.NamingException
- if an error occurspublic javax.naming.Context getContext()
public void setContext(javax.naming.Context context)
context
- the context
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |