Class 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 Info
      static 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 exist
      static 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 exist
      protected 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 class
      static void createLinkRef​(java.lang.String fromName, java.lang.String toName)
      Create a link
      static void createLinkRef​(javax.naming.Context ctx, java.lang.String fromName, java.lang.String toName)
      Create a link
      static 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 context
      static java.lang.Object lookup​(javax.naming.Context context, java.lang.String name, java.lang.Class clazz)
      Lookup an object in the given context
      static java.lang.Object lookup​(javax.naming.Context context, javax.naming.Name name, java.lang.Class clazz)
      Lookup an object in the given context
      static java.lang.Object lookup​(javax.naming.Name name, java.lang.Class<?> clazz)
      Lookup an object in the default initial context
      static 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 exist
      static 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 exist
      static void removeLinkRef​(java.lang.String name)
      Remove the link ref
      static void removeLinkRef​(javax.naming.Context ctx, java.lang.String name)
      Remove the link ref
      static void unbind​(javax.naming.Context ctx, java.lang.String name)
      Unbinds a name from ctx, and removes parents if they are empty
      static void unbind​(javax.naming.Context ctx, javax.naming.Name 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
    • Field Detail

      • log

        private static final org.jboss.logging.Logger log
    • Constructor Detail

      • Util

        public Util()
    • 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 bound
        name - 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 bound
        name - 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 bound
        name - the name relative to ctx where value will be bound
        value - 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 bound
        name - the name relative to ctx where value will be bound
        value - 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 bound
        name - the name relative to ctx where value will be bound
        value - 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 bound
        name - the name relative to ctx where value will be bound
        value - 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 unbound
        name - 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 unbound
        name - 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 lookup
        clazz - 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 lookup
        clazz - 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 context
        name - the name to lookup
        clazz - 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 context
        name - the name to lookup
        clazz - 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 name
        toName - 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 context
        fromName - the from name
        toName - 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 context
        name - 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 context
        name - the name to lookup
        object - the object
        clazz - 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 to
        clazz - the class to describe