Class 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 1234985 2012-01-23 21:09:09Z oheger $
    Author:
    Eric Pugh
    • Constructor Detail

      • JNDIConfiguration

        public JNDIConfiguration()
                          throws javax.naming.NamingException
        Creates 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​(java.lang.String prefix)
                          throws javax.naming.NamingException
        Creates 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
      • 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 context
        prefix - the prefix
    • Method Detail

      • getKeys

        public java.util.Iterator<java.lang.String> getKeys()
        Returns an iterator with all property keys stored in this configuration.
        Returns:
        an iterator with all keys
      • isEmpty

        public boolean isEmpty()
        Returns a flag whether this configuration is empty.
        Returns:
        the empty flag
      • setProperty

        public void setProperty​(java.lang.String key,
                                java.lang.Object value)

        This operation is not supported and will throw an UnsupportedOperationException.

        Specified by:
        setProperty in interface Configuration
        Overrides:
        setProperty in class AbstractConfiguration
        Parameters:
        key - the key
        value - the value
        Throws:
        java.lang.UnsupportedOperationException
      • containsKey

        public boolean containsKey​(java.lang.String key)
        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

        public java.lang.String getPrefix()
        Returns the prefix.
        Returns:
        the prefix
      • setPrefix

        public void setPrefix​(java.lang.String prefix)
        Sets the prefix.
        Parameters:
        prefix - The prefix to set
      • getProperty

        public java.lang.Object getProperty​(java.lang.String key)
        Returns the value of the specified property.
        Parameters:
        key - the key of the property
        Returns:
        the value of this property
      • addPropertyDirect

        protected void addPropertyDirect​(java.lang.String key,
                                         java.lang.Object obj)

        This operation is not supported and will throw an UnsupportedOperationException.

        Specified by:
        addPropertyDirect in class AbstractConfiguration
        Parameters:
        key - the key
        obj - the value
        Throws:
        java.lang.UnsupportedOperationException
      • getBaseContext

        public javax.naming.Context getBaseContext()
                                            throws javax.naming.NamingException
        Return 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()
        Return the initial context used by this configuration. This context is independent of the prefix specified.
        Returns:
        the initial context
      • setContext

        public void setContext​(javax.naming.Context context)
        Set the initial context of the configuration.
        Parameters:
        context - the context