Package org.jboss.util.naming
Class Util
- java.lang.Object
-
- org.jboss.util.naming.Util
-
public class Util extends java.lang.Object
A static utility class for common JNDI operations.- Version:
- $Revision$
-
-
Field Summary
Fields Modifier and Type Field Description private static org.jboss.logging.Logger
log
-
Constructor Summary
Constructors Constructor Description Util()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static void
appendClassInfo(java.lang.StringBuffer buffer, java.lang.Class clazz)
Append Class Infostatic void
bind(javax.naming.Context ctx, java.lang.String name, java.lang.Object value)
Bind val to name in ctx, and make sure that all intermediate contexts existstatic void
bind(javax.naming.Context ctx, javax.naming.Name name, java.lang.Object value)
Bind val to name in ctx, and make sure that all intermediate contexts existprotected static void
checkObject(javax.naming.Context context, java.lang.String name, java.lang.Object object, java.lang.Class clazz)
Checks an object implements the given classstatic void
createLinkRef(java.lang.String fromName, java.lang.String toName)
Create a linkstatic void
createLinkRef(javax.naming.Context ctx, java.lang.String fromName, java.lang.String toName)
Create a linkstatic javax.naming.Context
createSubcontext(javax.naming.Context ctx, java.lang.String name)
Create a subcontext including any intermediate contexts.static javax.naming.Context
createSubcontext(javax.naming.Context ctx, javax.naming.Name name)
Create a subcontext including any intermediate contexts.static java.lang.Object
lookup(java.lang.String name, java.lang.Class<?> clazz)
Lookup an object in the default initial contextstatic java.lang.Object
lookup(javax.naming.Context context, java.lang.String name, java.lang.Class clazz)
Lookup an object in the given contextstatic java.lang.Object
lookup(javax.naming.Context context, javax.naming.Name name, java.lang.Class clazz)
Lookup an object in the given contextstatic java.lang.Object
lookup(javax.naming.Name name, java.lang.Class<?> clazz)
Lookup an object in the default initial contextstatic void
rebind(javax.naming.Context ctx, java.lang.String name, java.lang.Object value)
Rebind val to name in ctx, and make sure that all intermediate contexts existstatic void
rebind(javax.naming.Context ctx, javax.naming.Name name, java.lang.Object value)
Rebind val to name in ctx, and make sure that all intermediate contexts existstatic void
removeLinkRef(java.lang.String name)
Remove the link refstatic void
removeLinkRef(javax.naming.Context ctx, java.lang.String name)
Remove the link refstatic void
unbind(javax.naming.Context ctx, java.lang.String name)
Unbinds a name from ctx, and removes parents if they are emptystatic void
unbind(javax.naming.Context ctx, javax.naming.Name name)
Unbinds a name from ctx, and removes parents if they are empty
-
-
-
Method Detail
-
createSubcontext
public static javax.naming.Context createSubcontext(javax.naming.Context ctx, java.lang.String name) throws javax.naming.NamingException
Create a subcontext including any intermediate contexts.- Parameters:
ctx
- the parent JNDI Context under which value will be boundname
- the name relative to ctx of the subcontext.- Returns:
- The new or existing JNDI subcontext
- Throws:
javax.naming.NamingException
- on any JNDI failure
-
createSubcontext
public static javax.naming.Context createSubcontext(javax.naming.Context ctx, javax.naming.Name name) throws javax.naming.NamingException
Create a subcontext including any intermediate contexts.- Parameters:
ctx
- the parent JNDI Context under which value will be boundname
- the name relative to ctx of the subcontext.- Returns:
- The new or existing JNDI subcontext
- Throws:
javax.naming.NamingException
- on any JNDI failure
-
bind
public static void bind(javax.naming.Context ctx, java.lang.String name, java.lang.Object value) throws javax.naming.NamingException
Bind val to name in ctx, and make sure that all intermediate contexts exist- Parameters:
ctx
- the parent JNDI Context under which value will be boundname
- the name relative to ctx where value will be boundvalue
- the value to bind.- Throws:
javax.naming.NamingException
- for any error
-
bind
public static void bind(javax.naming.Context ctx, javax.naming.Name name, java.lang.Object value) throws javax.naming.NamingException
Bind val to name in ctx, and make sure that all intermediate contexts exist- Parameters:
ctx
- the parent JNDI Context under which value will be boundname
- the name relative to ctx where value will be boundvalue
- the value to bind.- Throws:
javax.naming.NamingException
- for any error
-
rebind
public static void rebind(javax.naming.Context ctx, java.lang.String name, java.lang.Object value) throws javax.naming.NamingException
Rebind val to name in ctx, and make sure that all intermediate contexts exist- Parameters:
ctx
- the parent JNDI Context under which value will be boundname
- the name relative to ctx where value will be boundvalue
- the value to bind.- Throws:
javax.naming.NamingException
- for any error
-
rebind
public static void rebind(javax.naming.Context ctx, javax.naming.Name name, java.lang.Object value) throws javax.naming.NamingException
Rebind val to name in ctx, and make sure that all intermediate contexts exist- Parameters:
ctx
- the parent JNDI Context under which value will be boundname
- the name relative to ctx where value will be boundvalue
- the value to bind.- Throws:
javax.naming.NamingException
- for any error
-
unbind
public static void unbind(javax.naming.Context ctx, java.lang.String name) throws javax.naming.NamingException
Unbinds a name from ctx, and removes parents if they are empty- Parameters:
ctx
- the parent JNDI Context under which the name will be unboundname
- The name to unbind- Throws:
javax.naming.NamingException
- for any error
-
unbind
public static void unbind(javax.naming.Context ctx, javax.naming.Name name) throws javax.naming.NamingException
Unbinds a name from ctx, and removes parents if they are empty- Parameters:
ctx
- the parent JNDI Context under which the name will be unboundname
- The name to unbind- Throws:
javax.naming.NamingException
- for any error
-
lookup
public static java.lang.Object lookup(java.lang.String name, java.lang.Class<?> clazz) throws java.lang.Exception
Lookup an object in the default initial context- Parameters:
name
- the name to lookupclazz
- the expected type- Returns:
- the object
- Throws:
java.lang.Exception
- for any error
-
lookup
public static java.lang.Object lookup(javax.naming.Name name, java.lang.Class<?> clazz) throws java.lang.Exception
Lookup an object in the default initial context- Parameters:
name
- the name to lookupclazz
- the expected type- Returns:
- the object
- Throws:
java.lang.Exception
- for any error
-
lookup
public static java.lang.Object lookup(javax.naming.Context context, java.lang.String name, java.lang.Class clazz) throws java.lang.Exception
Lookup an object in the given context- Parameters:
context
- the contextname
- the name to lookupclazz
- the expected type- Returns:
- the object
- Throws:
java.lang.Exception
- for any error
-
lookup
public static java.lang.Object lookup(javax.naming.Context context, javax.naming.Name name, java.lang.Class clazz) throws java.lang.Exception
Lookup an object in the given context- Parameters:
context
- the contextname
- the name to lookupclazz
- the expected type- Returns:
- the object
- Throws:
java.lang.Exception
- for any error
-
createLinkRef
public static void createLinkRef(java.lang.String fromName, java.lang.String toName) throws javax.naming.NamingException
Create a link- Parameters:
fromName
- the from nametoName
- the to name- Throws:
javax.naming.NamingException
- for any error
-
createLinkRef
public static void createLinkRef(javax.naming.Context ctx, java.lang.String fromName, java.lang.String toName) throws javax.naming.NamingException
Create a link- Parameters:
ctx
- the contextfromName
- the from nametoName
- the to name- Throws:
javax.naming.NamingException
- for any error
-
removeLinkRef
public static void removeLinkRef(java.lang.String name) throws javax.naming.NamingException
Remove the link ref- Parameters:
name
- the name of the link binding- Throws:
javax.naming.NamingException
- for any error
-
removeLinkRef
public static void removeLinkRef(javax.naming.Context ctx, java.lang.String name) throws javax.naming.NamingException
Remove the link ref- Parameters:
ctx
- the contextname
- the name of the link binding- Throws:
javax.naming.NamingException
- for any error
-
checkObject
protected static void checkObject(javax.naming.Context context, java.lang.String name, java.lang.Object object, java.lang.Class clazz) throws java.lang.Exception
Checks an object implements the given class- Parameters:
context
- the contextname
- the name to lookupobject
- the objectclazz
- the expected type- Throws:
java.lang.Exception
- for any error
-
appendClassInfo
protected static void appendClassInfo(java.lang.StringBuffer buffer, java.lang.Class clazz)
Append Class Info- Parameters:
buffer
- the buffer to append toclazz
- the class to describe
-
-