de.smartics.properties.api.core.app
Class JndiContext

Package class diagram package JndiContext
java.lang.Object
  extended by de.smartics.properties.api.core.app.JndiContext

public final class JndiContext
     
     
extends Object

Defines constants for this library.


Field Summary
static String JNDI_CONTEXT_PATH_BOOT
          The path within the JNDI context to access boot configuration properties.
 
Method Summary
static JndiContext boot(Context context)
          Provides access to the boot properties within a JNDI context.
static JndiContext config(Context context, String configKey)
          Provides access to the custom properties within a JNDI context.
static List<String> configKeys(Context context)
          Returns the list of configuration keys.
static Object extensionConfig(Context context)
          Provides access to the extension configuration parameters within a JNDI context.
static String extensionConfigPath()
          Returns the JNDI path to the extension configuration.
 String getSourceId()
          Returns the name of the JNDI namespace.
 NamingEnumeration<NameClassPair> list()
          Returns the list of stored values in the context.
 String lookup(String key)
          Runs a lookup for the value with the given key in the JNDI context and returns the value as a String.
 Boolean lookupBoolean(String key)
          Runs a lookup for the value with the given key in the JNDI context.
 Object lookupObject(String key)
          Runs a lookup for the value with the given key in the JNDI context.
 void set(String key, Object value)
          Sets the value for the given key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JNDI_CONTEXT_PATH_BOOT

public static final String JNDI_CONTEXT_PATH_BOOT
The path within the JNDI context to access boot configuration properties.

Constant Field Value:
"/smartics-properties/boot"
Method Detail

boot

public static JndiContext boot(Context context)
                        throws IllegalArgumentException
Provides access to the boot properties within a JNDI context.

Parameters:
context - the root context.
Returns:
the JNDI context for boot properties.
Throws:
IllegalArgumentException - if the JNDI context cannot be initialized.

config

public static JndiContext config(Context context,
                                 String configKey)
                          throws IllegalArgumentException
Provides access to the custom properties within a JNDI context.

Parameters:
context - the custom context.
configKey - the key to the configuration. Will be used as a path within the context to set the root of the configuration.
Returns:
the JNDI context for custom properties.
Throws:
IllegalArgumentException - if the JNDI context cannot be initialized.

extensionConfig

public static Object extensionConfig(Context context)
                              throws NamingException
Provides access to the extension configuration parameters within a JNDI context.

The extension configuration contains properties to configure smartics-properties. It includes information for encrypting and decrypting property values, access information to data sources, etc. This information may also be provided in properties files on the class path. Having them added to JNDI via an extension is just another option to provided this information. Typically an extension is an application server specific implementation that allows to integrate the configuration parameters in a convenient way.

Parameters:
context - the root context.
Returns:
the JNDI context for configuration properties from the extension.
Throws:
NamingException - if the extension configuration cannot be retrieved.

extensionConfigPath

public static String extensionConfigPath()
Returns the JNDI path to the extension configuration.

Returns:
the JNDI path to the extension configuration.

configKeys

public static List<String> configKeys(Context context)
                               throws IllegalArgumentException
Returns the list of configuration keys.

Parameters:
context - the context within which to search for .
Returns:
the list of configuration keys as Strings.
Throws:
IllegalArgumentException - if the JNDI context cannot be accessed to fetch the configuration keys.

lookupObject

public Object lookupObject(String key)
                    throws NamingException
Runs a lookup for the value with the given key in the JNDI context.

Parameters:
key - the key to the value.
Returns:
the value to the key in the context.
Throws:
NamingException - on any problem accessing the value.

lookup

public String lookup(String key)
              throws NamingException
Runs a lookup for the value with the given key in the JNDI context and returns the value as a String.

Parameters:
key - the key to the value.
Returns:
the value to the key in the context.
Throws:
NamingException - on any problem accessing the value.

lookupBoolean

public Boolean lookupBoolean(String key)
                      throws NamingException
Runs a lookup for the value with the given key in the JNDI context.

Parameters:
key - the key to the value.
Returns:
the value to the key in the context.
Throws:
NamingException - on any problem accessing the value.

set

public void set(String key,
                Object value)
         throws NamingException
Sets the value for the given key.

Parameters:
key - the key to the value.
value - the value to the key in the context.
Throws:
NamingException - on any problem accessing the value.

list

public NamingEnumeration<NameClassPair> list()
                                      throws NamingException
Returns the list of stored values in the context.

Returns:
the list of stored values in the context.
Throws:
NamingException - on any problem accessing the naming context.

getSourceId

public String getSourceId()
Returns the name of the JNDI namespace.

Returns:
the name of the JNDI namespace.


Copyright © 2012-2013 Kronseder & Reiner GmbH - smartics. All Rights Reserved.