Package ejava.util.jndi
Class JNDIUtil
- java.lang.Object
-
- ejava.util.jndi.JNDIUtil
-
public class JNDIUtil extends Object
This class helps work with the JNDI tree.
-
-
Field Summary
Fields Modifier and Type Field Description private static org.slf4j.Logger
logger
private static String[]
PATHS
static String
PROPERTY_FILE
-
Constructor Summary
Constructors Constructor Description JNDIUtil()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
doDump(int level, StringBuilder text, Context context, String name)
String
dump()
Produces a debug string listing the JNDI contents of the current, default Context.String
dump(Context context, String name)
Produces a debug string listing the JNDI contents of the specified Context.static InitialContext
getInitialContext(String propertiesPath)
static Properties
getJNDIProperties(String prefix)
This method will return a jndi.properties object that is based on the properties found in ejava-jndi.properties that start with the provided prefix.protected String
getPad(int level)
protected boolean
isContext(String className)
static <T> T
lookup(Context ctx, Class<T> type, String name, int waitSecs)
Performs a JNDI lookup and will wait supplied number of seconds before giving up.
-
-
-
Field Detail
-
logger
private static final org.slf4j.Logger logger
-
PROPERTY_FILE
public static final String PROPERTY_FILE
- See Also:
- Constant Field Values
-
PATHS
private static final String[] PATHS
-
-
Method Detail
-
getInitialContext
public static InitialContext getInitialContext(String propertiesPath) throws IOException, NamingException
- Throws:
IOException
NamingException
-
getJNDIProperties
public static Properties getJNDIProperties(String prefix) throws IOException
This method will return a jndi.properties object that is based on the properties found in ejava-jndi.properties that start with the provided prefix. This method is useful when examples are using different JNDI mechanisms and want to keep them separate by forming the jndi.properties in memory.- Parameters:
prefix
-- Returns:
- Properties object that can be used during a new InitialContext(env)
- Throws:
IOException
-
lookup
public static <T> T lookup(Context ctx, Class<T> type, String name, int waitSecs) throws NamingException
Performs a JNDI lookup and will wait supplied number of seconds before giving up.- Parameters:
ctx
-type
-name
-waitSecs
-- Returns:
- Object resolved from the lookup
- Throws:
NamingException
-
dump
public String dump() throws NamingException
Produces a debug string listing the JNDI contents of the current, default Context.- Returns:
- String describing contents of context
- Throws:
NamingException
-
dump
public String dump(Context context, String name)
Produces a debug string listing the JNDI contents of the specified Context.- Parameters:
context
-name
-- Returns:
- String describing contents of context
-
doDump
private void doDump(int level, StringBuilder text, Context context, String name) throws NamingException
- Throws:
NamingException
-
isContext
protected boolean isContext(String className)
-
getPad
protected String getPad(int level)
-
-