EAF 7.6 Util

org.enhydra.util
Class JNDIAdapter

java.lang.Object
  extended by org.enhydra.util.JNDIAdapter

public class JNDIAdapter
extends java.lang.Object

This class is used for reading configuration parameters using JNDI. It coresponds between InitialContext object and application's Config and ConfigFile object.

Version:
1.0
Author:
Tanja Jovanovic

Field Summary
static java.lang.String CONTEXT_FOR_ENV_BIND
          Application component Context environment.
static java.lang.String FILE_JNDI_ABS_PATH_NAME
          Absolute path to application configuration file.
 
Constructor Summary
JNDIAdapter()
          Default constructor for empty adapter.
JNDIAdapter(java.lang.String fileAbsolutePath, java.lang.String factoryClass)
          Constructor with defined file.
 
Method Summary
 boolean containsKey(java.lang.String key)
          Returns true if the specified key is found, false otherwise.
 java.lang.Object get(java.lang.String keyword)
          Get the value of a field as an object.
 java.lang.Object get(java.lang.String keyword, java.lang.Object defaultValue)
          Get the value of a field as an object, return a default if it does not exist.
 java.lang.Object getResource(java.lang.String jndiName)
           
 java.lang.String[] getStrings(java.lang.String key)
          Get the value of a field as String array.
static boolean isArray(java.lang.String key)
          Returns true if key has indicator that the field is array (the key ends with "[]")
 java.lang.String[] keys()
          Get the keywords in the table.
 java.lang.String[] leafKeys()
          Recursively get the keywords for the entire table.
static java.lang.String makeConfigString(java.lang.String oldString)
          From Context String (delimiters are / signs) makes Config String (delimiters are . signs).
static java.lang.String makeContextString(java.lang.String oldString)
          From Config String (delimiters are . signs) makes Context String (delimiters are / signs).
static java.lang.String makeStringFromStrings(java.lang.String[] strings)
          From String array makes String in which are String array elements separated with , sign.
 void remove(java.lang.String keyword)
          Removes field with the defined key.
 java.lang.String removeArrayMark(java.lang.String key)
          Removes array indicator (the key ends with "[]") if exists.
 void set(java.lang.String keyword, java.lang.String value)
          Sets the value of a field with the defined key.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_JNDI_ABS_PATH_NAME

public static final java.lang.String FILE_JNDI_ABS_PATH_NAME
Absolute path to application configuration file.

See Also:
Constant Field Values

CONTEXT_FOR_ENV_BIND

public static final java.lang.String CONTEXT_FOR_ENV_BIND
Application component Context environment.

See Also:
Constant Field Values
Constructor Detail

JNDIAdapter

public JNDIAdapter()
Default constructor for empty adapter.


JNDIAdapter

public JNDIAdapter(java.lang.String fileAbsolutePath,
                   java.lang.String factoryClass)
Constructor with defined file. This is used if file other than web.xml is used for reading Application's parameters with JNDI.

Parameters:
fileAbsolutePath - absolute file path.
factoryClass - InitialContextFactory class used for creating application InitialContext.
Method Detail

containsKey

public boolean containsKey(java.lang.String key)
Returns true if the specified key is found, false otherwise.

Parameters:
key - The key whose existence is to be tested.
Returns:
true if the key was found, otherwise false.

keys

public java.lang.String[] keys()
Get the keywords in the table. This is only the keywords at the top level, its doesn't recurse.

Returns:
An string array of the keywords.

leafKeys

public java.lang.String[] leafKeys()
Recursively get the keywords for the entire table. This returns the full keyword of all leaf values.

Returns:
An string array of the keywords.

get

public java.lang.Object get(java.lang.String keyword)
                     throws javax.naming.NamingException
Get the value of a field as an object.

Parameters:
keyword - The keyword of the field. This can be a simple keyword or a recursive, dot-seperated keyword path.
Returns:
The object value or null if its not found.
Throws:
com.lutris.util.KeywordValueException - If the keyword is not syntactically legal or is a non-leaf element of the keyword is not a section.
javax.naming.NamingException

get

public java.lang.Object get(java.lang.String keyword,
                            java.lang.Object defaultValue)
                     throws javax.naming.NamingException
Get the value of a field as an object, return a default if it does not exist.

Parameters:
keyword - The keyword of the field. This can be a simple keyword or a recursive, dot-seperated keyword path.
defaultValue - The default value to return it the keyword does not exist.
Returns:
The object value or defaultValue if its not found.
Throws:
com.lutris.util.KeywordValueException - If the keyword is not syntactically legal or is a non-leaf element of the keyword is not a section.
javax.naming.NamingException

getResource

public java.lang.Object getResource(java.lang.String jndiName)
                             throws javax.naming.NamingException
Throws:
javax.naming.NamingException

set

public void set(java.lang.String keyword,
                java.lang.String value)
Sets the value of a field with the defined key.

Parameters:
keyword - The keyword of the field.
value - The new field value.

remove

public void remove(java.lang.String keyword)
Removes field with the defined key.

Parameters:
keyword - The keyword of the field.

makeConfigString

public static java.lang.String makeConfigString(java.lang.String oldString)
From Context String (delimiters are / signs) makes Config String (delimiters are . signs).

Parameters:
oldString - Context String
Returns:
Transformed Config String.

makeContextString

public static java.lang.String makeContextString(java.lang.String oldString)
From Config String (delimiters are . signs) makes Context String (delimiters are / signs).

Parameters:
oldString - Config String
Returns:
Transformed Context String.

makeStringFromStrings

public static java.lang.String makeStringFromStrings(java.lang.String[] strings)
From String array makes String in which are String array elements separated with , sign.

Parameters:
strings - String array.
Returns:
Transformed String.

isArray

public static boolean isArray(java.lang.String key)
Returns true if key has indicator that the field is array (the key ends with "[]")

Parameters:
key - The keyword of the field.
Returns:
true if key has indicator that the field is array, otherwise false.

removeArrayMark

public java.lang.String removeArrayMark(java.lang.String key)
Removes array indicator (the key ends with "[]") if exists.

Parameters:
key - The keyword of the field.
Returns:
Keyword without "[]".

getStrings

public java.lang.String[] getStrings(java.lang.String key)
Get the value of a field as String array.

Parameters:
key - The keyword of the field. This can be a simple keyword or a recursive, dot-seperated keyword path.
Returns:
The object value as String[] or null if its not found.

EAF 7.6 Util