org.apache.commons.configuration
Class JNDIConfiguration

java.lang.Object
  extended byorg.apache.commons.configuration.AbstractConfiguration
      extended byorg.apache.commons.configuration.JNDIConfiguration
All Implemented Interfaces:
Configuration

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.

Version:
$Id: JNDIConfiguration.java 155408 2005-02-26 12:56:39Z dirkv $
Author:
Eric Pugh

Field Summary
 
Fields inherited from class org.apache.commons.configuration.AbstractConfiguration
END_TOKEN, START_TOKEN
 
Constructor Summary
JNDIConfiguration()
          Creates a JNDIConfiguration using the default initial context 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.
JNDIConfiguration(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(String key, Object obj)
          This operation is not supported and will throw an UnsupportedOperationException.
 void clearProperty(String key)
          Remove a property from the configuration.
 boolean containsKey(String key)
          Check if the configuration contains the specified key.
 Context getBaseContext()
          Return the base context with the prefix applied.
 Context getContext()
          Return the initial context used by this configuration.
 Iterator getKeys()
          Get the list of the keys contained in the configuration.
 Iterator getKeys(String prefix)
          Get the list of the keys contained in the configuration that match the specified prefix.
 String getPrefix()
           
 Object getProperty(String key)
          Gets a property from the configuration.
 boolean isEmpty()
          Check if the configuration is empty.
 void setContext(Context context)
          Set the initial context of the configuration.
 void setPrefix(String prefix)
          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
addProperty, clear, getBigDecimal, getBigDecimal, getBigInteger, getBigInteger, getBoolean, getBoolean, getBoolean, getByte, getByte, getByte, getDelimiter, getDouble, getDouble, getDouble, getFloat, getFloat, getFloat, getInt, getInt, getInteger, getList, getList, getLong, getLong, getLong, getProperties, getProperties, getShort, getShort, getShort, getString, getString, getStringArray, interpolate, interpolateHelper, isThrowExceptionOnMissing, resolveContainerStore, setDelimiter, setThrowExceptionOnMissing, subset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JNDIConfiguration

public JNDIConfiguration()
                  throws NamingException
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

public JNDIConfiguration(String prefix)
                  throws NamingException
Creates a JNDIConfiguration using the default initial context, shifted with the specified prefix, as the root of the properties.

Parameters:
prefix -
Throws:
NamingException - thrown if an error occurs when initializing the default context

JNDIConfiguration

public JNDIConfiguration(Context context)
Creates a JNDIConfiguration using the specified initial context as the root of the properties.

Parameters:
context - the initial context

JNDIConfiguration

public JNDIConfiguration(Context context,
                         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 context
prefix -
Method Detail

getKeys

public Iterator getKeys()
Get the list of the keys contained in the configuration.

Specified by:
getKeys in interface Configuration
Specified by:
getKeys in class AbstractConfiguration

getKeys

public Iterator getKeys(String prefix)
Get the list of the keys contained in the configuration that match the specified prefix.

Specified by:
getKeys in interface Configuration
Overrides:
getKeys in class AbstractConfiguration

isEmpty

public boolean isEmpty()
Check if the configuration is empty.

Specified by:
isEmpty in interface Configuration
Specified by:
isEmpty in class AbstractConfiguration

setProperty

public void setProperty(String key,
                        Object value)

This operation is not supported and will throw an UnsupportedOperationException.

Specified by:
setProperty in interface Configuration
Overrides:
setProperty in class AbstractConfiguration
Throws:
UnsupportedOperationException

clearProperty

public void clearProperty(String key)
Remove a property from the configuration.

Specified by:
clearProperty in interface Configuration
Specified by:
clearProperty in class AbstractConfiguration

containsKey

public boolean containsKey(String key)
Check if the configuration contains the specified key.

Specified by:
containsKey in interface Configuration
Specified by:
containsKey in class AbstractConfiguration

getPrefix

public String getPrefix()
Returns:
String

setPrefix

public void setPrefix(String prefix)
Sets the prefix.

Parameters:
prefix - The prefix to set

getProperty

public Object getProperty(String key)
Gets a property from the configuration.

Parameters:
key - property to retrieve
Returns:
the value to which this configuration maps the specified key, or null if the configuration contains no mapping for this key.

addPropertyDirect

protected void addPropertyDirect(String key,
                                 Object obj)

This operation is not supported and will throw an UnsupportedOperationException.

Specified by:
addPropertyDirect in class AbstractConfiguration
Parameters:
key - key to use for mapping
obj - object to store
Throws:
UnsupportedOperationException

getBaseContext

public Context getBaseContext()
                       throws NamingException
Return the base context with the prefix applied.

Throws:
NamingException

getContext

public Context getContext()
Return the initial context used by this configuration. This context is independent of the prefix specified.


setContext

public void setContext(Context context)
Set the initial context of the configuration.



Copyright © 2001-2005 The Apache Software Foundation. All Rights Reserved.