net.larsan.urd.util
Class ContextUtils

java.lang.Object
  |
  +--net.larsan.urd.util.ContextUtils

public class ContextUtils
extends java.lang.Object

This class contains some static helper methods for jndi context operations

Version:
Alpha-0.1 / 2002-10-06 21:37
Author:
Lars J. Nilsson

Constructor Summary
ContextUtils()
           
 
Method Summary
static void creationBind(javax.naming.Context con, java.lang.String name, java.lang.Object object)
          Do a bind and attempt to create all non-existent subcontexts needed by the name.
static void creationRebind(javax.naming.Context con, java.lang.String name, java.lang.Object object)
          Do a rebind and attempt to create all non-existent subcontexts needed by the name.
static boolean isBound(javax.naming.Context con, java.lang.String name)
          Check if a name is bound in the context.
static java.lang.Object nullReturnLookup(javax.naming.Context con, java.lang.String name)
          Do a lookup for a name and return null if the name is not bound to an object in the context.
static javax.naming.Context subcontextCreation(javax.naming.Context con, java.lang.String name)
          Create subcontext plus all intermediate contexts.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContextUtils

public ContextUtils()
Method Detail

isBound

public static boolean isBound(javax.naming.Context con,
                              java.lang.String name)
                       throws javax.naming.NamingException
Check if a name is bound in the context. This returns true only if the whole name plus its subcontexts is found.

Parameters:
name - Name to check for
Returns:
true If the name is bound in the context
Throws:
javax.naming.NamingException - On naming errors

nullReturnLookup

public static java.lang.Object nullReturnLookup(javax.naming.Context con,
                                                java.lang.String name)
                                         throws javax.naming.NamingException
Do a lookup for a name and return null if the name is not bound to an object in the context. This swallows NameNotFoundExceptions and NotContextExceptions in the name of simplicity.

Parameters:
name - Name to lookup
Returns:
An object bound to the name, or null if not found
Throws:
javax.naming.NamingException - On naming errors

subcontextCreation

public static javax.naming.Context subcontextCreation(javax.naming.Context con,
                                                      java.lang.String name)
                                               throws javax.naming.NamingException
Create subcontext plus all intermediate contexts.

Parameters:
name - Subcontext name to create
Returns:
A new subcontext
Throws:
javax.naming.NamingException - If the subcontext creation fails

creationBind

public static void creationBind(javax.naming.Context con,
                                java.lang.String name,
                                java.lang.Object object)
                         throws javax.naming.NamingException
Do a bind and attempt to create all non-existent subcontexts needed by the name.

Parameters:
name - Name to bind to
object - Object to bind
Returns:
An object bound to the name, or null if not found
Throws:
javax.naming.NamingException - On naming errors

creationRebind

public static void creationRebind(javax.naming.Context con,
                                  java.lang.String name,
                                  java.lang.Object object)
                           throws javax.naming.NamingException
Do a rebind and attempt to create all non-existent subcontexts needed by the name.

Parameters:
name - Name to bind to
object - Object to bind
Returns:
An object bound to the name, or null if not found
Throws:
javax.naming.NamingException - On naming errors