Package org.jboss.as.naming.util
Class NamingUtils
- java.lang.Object
-
- org.jboss.as.naming.util.NamingUtils
-
public class NamingUtils extends Object
Common utility functions used by the naming implementation.- Author:
- John E. Bailey
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static CannotProceedExceptioncannotProceedException(Object resolvedObject, Name remainingName)Return a cannot-proceed exception.static InvalidNameExceptionemptyNameException()Create an invalid name exception for an empty name.static StringgetLastComponent(Name name)Get the last component of a name.static booleanisEmpty(Name name)Determine if a name is empty, or if ot contains only one component which is the empty string.static booleanisLastComponentEmpty(Name name)Determine whether the last component is empty.static NameAlreadyBoundExceptionnameAlreadyBoundException(Name name)Create a name-already-bound exception.static NameNotFoundExceptionnameNotFoundException(String name, Name contextName)Create a name-not-found exception.static <T> NamingEnumeration<T>namingEnumeration(Collection<T> collection)Return a naming enumeration over a collection.static NamingExceptionnamingException(String message, Throwable cause)Return a general naming exception with a root cause.static NamingExceptionnamingException(String message, Throwable cause, Name remainingName)Return a general naming exception with a root cause and a remaining name field.static NotContextExceptionnotAContextException(Name name)Return a not-context exception for a name.static voidrebind(Context ctx, String name, Object value)Rebind val to name in ctx, and make sure that all intermediate contexts existstatic voidrebind(Context ctx, Name name, Object value)Rebind val to name in ctx, and make sure that all intermediate contexts existstatic voidunbind(Context ctx, String name)Unbinds a name from ctx, and removes parents if they are emptystatic voidunbind(Context ctx, Name name)Unbinds a name from ctx, and removes parents if they are empty
-
-
-
Method Detail
-
getLastComponent
public static String getLastComponent(Name name)
Get the last component of a name.- Parameters:
name- the name- Returns:
- the last component
-
isEmpty
public static boolean isEmpty(Name name)
Determine if a name is empty, or if ot contains only one component which is the empty string.- Parameters:
name- the name- Returns:
trueif the name is empty or contains one empty component
-
isLastComponentEmpty
public static boolean isLastComponentEmpty(Name name)
Determine whether the last component is empty.- Parameters:
name- the name to test- Returns:
trueif the last component is empty, or if the name is empty
-
nameNotFoundException
public static NameNotFoundException nameNotFoundException(String name, Name contextName)
Create a name-not-found exception.- Parameters:
name- the namecontextName- the context name- Returns:
- the exception
-
nameAlreadyBoundException
public static NameAlreadyBoundException nameAlreadyBoundException(Name name)
Create a name-already-bound exception.- Parameters:
name- the name- Returns:
- the exception
-
emptyNameException
public static InvalidNameException emptyNameException()
Create an invalid name exception for an empty name.- Returns:
- the exception
-
notAContextException
public static NotContextException notAContextException(Name name)
Return a not-context exception for a name.- Parameters:
name- the name- Returns:
- the exception
-
namingException
public static NamingException namingException(String message, Throwable cause)
Return a general naming exception with a root cause.- Parameters:
message- the messagecause- the exception cause, ornullfor none- Returns:
- the exception
-
namingException
public static NamingException namingException(String message, Throwable cause, Name remainingName)
Return a general naming exception with a root cause and a remaining name field.- Parameters:
message- the messagecause- the exception cause, ornullfor noneremainingName- the remaining name- Returns:
- the exception
-
cannotProceedException
public static CannotProceedException cannotProceedException(Object resolvedObject, Name remainingName)
Return a cannot-proceed exception.- Parameters:
resolvedObject- the resolved objectremainingName- the remaining name- Returns:
- the exception
-
namingEnumeration
public static <T> NamingEnumeration<T> namingEnumeration(Collection<T> collection)
Return a naming enumeration over a collection.- Type Parameters:
T- the member type- Parameters:
collection- the collection- Returns:
- the enumeration
-
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 boundname- the name relative to ctx where value will be boundvalue- the value to bind.- Throws:
NamingException- for any error
-
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 boundname- the name relative to ctx where value will be boundvalue- the value to bind.- Throws:
NamingException- for any error
-
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 unboundname- The name to unbind- Throws:
NamingException- for any error
-
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 unboundname- The name to unbind- Throws:
NamingException- for any error
-
-