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,v 1.19 2004/10/04 20:06:09 ebourg Exp $
Author:
Eric Pugh

Nested Class Summary
 
Nested classes inherited from class org.apache.commons.configuration.AbstractConfiguration
AbstractConfiguration.PropertiesTokenizer
 
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
 void addProperty(String key, Object token)
          JNDIConfigurations can not be added to.
protected  void addPropertyDirect(String key, Object obj)
          Adds a key/value pair to the Configuration. Override this method to provide write acces to underlying Configuration store.
 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()
           
 Properties getProperties(String key)
          Get a list of properties associated with the given configuration key. This operation is not supported
 Object getProperty(String key)
          Gets a property from the configuration.
protected  Object getPropertyDirect(String key)
          Read property. Should return null if the key doesn't map to an existing object.
 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)
          Set a property, this will replace any previously set values. Set values is implicitly a call to clearProperty(key), addProperty(key, value).
 
Methods inherited from class org.apache.commons.configuration.AbstractConfiguration
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, getShort, getShort, getShort, getString, getString, getStringArray, getVector, getVector, interpolate, interpolateHelper, isThrowExceptionOnMissing, setDelimiter, setThrowExceptionOnMissing, split, 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

addProperty

public void addProperty(String key,
                        Object token)
JNDIConfigurations can not be added to.

Specified by:
addProperty in interface Configuration
Overrides:
addProperty in class AbstractConfiguration
Parameters:
key - The Key to add the property to.
token - The Value to add.

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

getProperties

public Properties getProperties(String key)
Get a list of properties associated with the given configuration key. This operation is not supported

Specified by:
getProperties in interface Configuration
Overrides:
getProperties 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

getProperty

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

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

setProperty

public void setProperty(String key,
                        Object value)
Set a property, this will replace any previously set values. Set values is implicitly a call to clearProperty(key), addProperty(key, value).

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

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

getPropertyDirect

protected Object getPropertyDirect(String key)
Read property. Should return null if the key doesn't map to an existing object.

Specified by:
getPropertyDirect in class AbstractConfiguration
Parameters:
key - key to use for mapping
Returns:
object associated with the given configuration key.

addPropertyDirect

protected void addPropertyDirect(String key,
                                 Object obj)
Adds a key/value pair to the Configuration. Override this method to provide write acces to underlying Configuration store.

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

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-2004 The Apache Software Foundation. All Rights Reserved.