org.jboss.util.naming
Class Util

java.lang.Object
  extended by org.jboss.util.naming.Util

public class Util
extends Object

A static utility class for common JNDI operations.

Version:
$Revision: 1.3.2.2 $
Author:
Scott.Stark@jboss.org, adrian@jboss.com

Constructor Summary
Util()
           
 
Method Summary
protected static void appendClassInfo(StringBuffer buffer, Class clazz)
          Append Class Info
static void bind(Context ctx, Name name, Object value)
          Bind val to name in ctx, and make sure that all intermediate contexts exist
static void bind(Context ctx, String name, Object value)
          Bind val to name in ctx, and make sure that all intermediate contexts exist
protected static void checkObject(Context context, String name, Object object, Class clazz)
          Checks an object implements the given class
static void createLinkRef(Context ctx, String fromName, String toName)
          Create a link
static void createLinkRef(String fromName, String toName)
          Create a link
static Context createSubcontext(Context ctx, Name name)
          Create a subcontext including any intermediate contexts.
static Context createSubcontext(Context ctx, String name)
          Create a subcontext including any intermediate contexts.
static Object lookup(Context context, Name name, Class clazz)
          Lookup an object in the given context
static Object lookup(Context context, String name, Class clazz)
          Lookup an object in the given context
static Object lookup(Name name, Class clazz)
          Lookup an object in the default initial context
static Object lookup(String name, Class clazz)
          Lookup an object in the default initial context
static void rebind(Context ctx, Name name, Object value)
          Rebind val to name in ctx, and make sure that all intermediate contexts exist
static void rebind(Context ctx, String name, Object value)
          Rebind val to name in ctx, and make sure that all intermediate contexts exist
static void removeLinkRef(Context ctx, String name)
          Remove the link ref
static void removeLinkRef(String name)
          Remove the link ref
static void unbind(Context ctx, Name name)
          Unbinds a name from ctx, and removes parents if they are empty
static void unbind(Context ctx, String name)
          Unbinds a name from ctx, and removes parents if they are empty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Util

public Util()
Method Detail

createSubcontext

public static Context createSubcontext(Context ctx,
                                       String name)
                                throws NamingException
Create a subcontext including any intermediate contexts.

Parameters:
ctx, - the parent JNDI Context under which value will be bound
name, - the name relative to ctx of the subcontext.
Returns:
The new or existing JNDI subcontext
Throws:
NamingException - on any JNDI failure

createSubcontext

public static Context createSubcontext(Context ctx,
                                       Name name)
                                throws NamingException
Create a subcontext including any intermediate contexts.

Parameters:
ctx, - the parent JNDI Context under which value will be bound
name, - the name relative to ctx of the subcontext.
Returns:
The new or existing JNDI subcontext
Throws:
NamingException - on any JNDI failure

bind

public static void bind(Context ctx,
                        String name,
                        Object value)
                 throws 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 bound
name, - the name relative to ctx where value will be bound
value, - the value to bind.
Throws:
NamingException

bind

public static void bind(Context ctx,
                        Name name,
                        Object value)
                 throws 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 bound
name, - the name relative to ctx where value will be bound
value, - the value to bind.
Throws:
NamingException

rebind

public static void rebind(Context ctx,
                          String name,
                          Object value)
                   throws 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 bound
name, - the name relative to ctx where value will be bound
value, - the value to bind.
Throws:
NamingException

rebind

public static void rebind(Context ctx,
                          Name name,
                          Object value)
                   throws 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 bound
name, - the name relative to ctx where value will be bound
value, - the value to bind.
Throws:
NamingException

unbind

public static void unbind(Context ctx,
                          String name)
                   throws 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 unbound
name, - The name to unbind
Throws:
NamingException

unbind

public static void unbind(Context ctx,
                          Name name)
                   throws 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 unbound
name, - The name to unbind
Throws:
NamingException

lookup

public static Object lookup(String name,
                            Class clazz)
                     throws Exception
Lookup an object in the default initial context

Parameters:
name - the name to lookup
clazz - the expected type
Returns:
the object
Throws:
Exception - for any error

lookup

public static Object lookup(Name name,
                            Class clazz)
                     throws Exception
Lookup an object in the default initial context

Parameters:
name - the name to lookup
clazz - the expected type
Returns:
the object
Throws:
Exception - for any error

lookup

public static Object lookup(Context context,
                            String name,
                            Class clazz)
                     throws Exception
Lookup an object in the given context

Parameters:
context - the context
name - the name to lookup
clazz - the expected type
Returns:
the object
Throws:
Exception - for any error

lookup

public static Object lookup(Context context,
                            Name name,
                            Class clazz)
                     throws Exception
Lookup an object in the given context

Parameters:
context - the context
name - the name to lookup
clazz - the expected type
Returns:
the object
Throws:
Exception - for any error

createLinkRef

public static void createLinkRef(String fromName,
                                 String toName)
                          throws NamingException
Create a link

Parameters:
fromName - the from name
toName - the to name
Throws:
NamingException - for any error

createLinkRef

public static void createLinkRef(Context ctx,
                                 String fromName,
                                 String toName)
                          throws NamingException
Create a link

Parameters:
ctx - the context
fromName - the from name
toName - the to name
Throws:
NamingException - for any error

removeLinkRef

public static void removeLinkRef(String name)
                          throws NamingException
Remove the link ref

Parameters:
name - the name of the link binding
Throws:
NamingException - for any error

removeLinkRef

public static void removeLinkRef(Context ctx,
                                 String name)
                          throws NamingException
Remove the link ref

Parameters:
ctx - the context
name - the name of the link binding
Throws:
NamingException - for any error

checkObject

protected static void checkObject(Context context,
                                  String name,
                                  Object object,
                                  Class clazz)
                           throws Exception
Checks an object implements the given class

Parameters:
context - the context
name - the name to lookup
object - the object
clazz - the expected type
Throws:
Exception

appendClassInfo

protected static void appendClassInfo(StringBuffer buffer,
                                      Class clazz)
Append Class Info

Parameters:
buffer - the buffer to append to
clazz - the class to describe


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.