com.onewebsql.util.jndi
Class JndiUtil

java.lang.Object
  extended by com.onewebsql.util.jndi.JndiUtil

public class JndiUtil
extends Object

This class provides methods with a full contract of JNDI operations execution JndiOp. The JNDI operation executed through this class automatically opens, closes contexts and handles exceptions NamingException.


Constructor Summary
JndiUtil()
          Constructor with default JNDI context provider (InitialContextProvider).
JndiUtil(ContextProvider contextProvider)
          Constructor with provided JNDI context provider.
 
Method Summary
<T> T
lookup(String name)
          Searches for an object with the specified JNDI name in a JNDI context of this class.
<T> T
lookup(String name, Context ctx)
          Searches for an object with the specified JNDI name in a specified JNDI context.
<T> T
withContext(JndiOp<T> operation, Context ctx)
          Executes JNDI operation in a provided JNDI context.
<T> T
withInitialContext(JndiOp<T> operation)
          Executes JNDI operation in JNDI context of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JndiUtil

public JndiUtil()
Constructor with default JNDI context provider (InitialContextProvider).


JndiUtil

public JndiUtil(ContextProvider contextProvider)
Constructor with provided JNDI context provider.

Parameters:
contextProvider - JNDI context provider.
Method Detail

withInitialContext

public <T> T withInitialContext(JndiOp<T> operation)
Executes JNDI operation in JNDI context of this class. The method creates new context object InitialContext and closes it even if the operation was not successful or threw an exception.

Type Parameters:
T - typ wyniku operacji.
Parameters:
operation - operacja do wykonania.
Returns:
wynik wykonania operacji.

withContext

public <T> T withContext(JndiOp<T> operation,
                         Context ctx)
Executes JNDI operation in a provided JNDI context.

Type Parameters:
T - typ wyniku operacji.
Parameters:
operation - operacja wymagajÄ…ca kontekstu JNDI.
ctx - kontekst JNDI przekazywany do operacji.
Returns:
wynik wykonania operacji.

lookup

public <T> T lookup(String name)
Searches for an object with the specified JNDI name in a JNDI context of this class.

Type Parameters:
T - type of the object in JNDI.
Parameters:
name - JNDI name of the object.
Returns:
the object with a specified JNDI name

lookup

public <T> T lookup(String name,
                    Context ctx)
Searches for an object with the specified JNDI name in a specified JNDI context.

Type Parameters:
T - type of the object in JNDI.
Parameters:
name - JNDI name of the object.
ctx - JNDI context to search for the object.
Returns:
the object with a specified JNDI name


Copyright © 2011-2013 e-point SA. All Rights Reserved.