|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.naming.ContextBindings
public class ContextBindings
Maintains bindings associating user-defined names, NamingContexts, threads
and classloaders. User-defined names are bound to contexts using
bindContext.
Threads and classloaders are bound to
NamingContexts indirectly, using bindXxx
methods that take
user-defined context names as parameters. The currently executing thread
and the context classloaders of the current thread are implicit arguments to
the thread and classloader binding methods -- that is, it is only possible
to bind the current thread and its context classloader.
If a context name has a security token associated with it (set using
ContextAccessController.setSecurityToken(Object,Object)
), this token
must be supplied to bind and unbind methods.
Key | Value | Bind methods | Lookup method |
---|---|---|---|
User-defined name | NamingContext | bindContext(Object,Context) ,
bindContext(Object,Context,Object) |
none |
Thread | NamingContext | bindThread(Object) ,
bindThread(Object, Object) |
getThread() |
ClassLoader | NamingContext | bindClassLoader(Object, Object) ,
bindClassLoader(Object,Object, ClassLoader) |
getClassLoader() |
Also includes unbind
methods and methods for determining
whether or not classloaders and threads are bound to contexts.
Field Summary | |
---|---|
protected static StringManager |
sm
The string manager for this package. |
Constructor Summary | |
---|---|
ContextBindings()
|
Method Summary | |
---|---|
static void |
bindClassLoader(java.lang.Object name)
Binds a naming context to the context ClassLoader for the currently executing thread. |
static void |
bindClassLoader(java.lang.Object name,
java.lang.Object token)
Binds a naming context to the context ClassLoader for the currently executing thread. |
static void |
bindClassLoader(java.lang.Object name,
java.lang.Object token,
java.lang.ClassLoader classLoader)
Binds a naming context to a ClassLoader. |
static void |
bindContext(java.lang.Object name,
javax.naming.Context context)
Binds a context name. |
static void |
bindContext(java.lang.Object name,
javax.naming.Context context,
java.lang.Object token)
Binds a context name. |
static void |
bindThread(java.lang.Object name)
Binds a naming context to the currently executing thread. |
static void |
bindThread(java.lang.Object name,
java.lang.Object token)
Binds a naming context to the currently executing thread. |
static javax.naming.Context |
getClassLoader()
Retrieves the naming context bound to the context ClassLoader for the currently executing thread, if that ClassLoader is bound. |
static javax.naming.Context |
getThread()
Retrieves the naming context bound to the currently executing thread. |
static boolean |
isClassLoaderBound()
Tests if current class loader is bound to a context. |
static boolean |
isThreadBound()
Tests if current thread is bound to a context. |
static void |
unbindClassLoader(java.lang.Object name)
Unbinds a naming context from the context ClassLoader for the currently executing thread. |
static void |
unbindClassLoader(java.lang.Object name,
java.lang.Object token)
Unbinds a naming context from the context ClassLoader for the currently executing thread. |
static void |
unbindClassLoader(java.lang.Object name,
java.lang.Object token,
java.lang.ClassLoader classLoader)
Unbinds a naming context from a class loader. |
static void |
unbindContext(java.lang.Object name)
Unbinds a context name. |
static void |
unbindContext(java.lang.Object name,
java.lang.Object token)
Unbinds a context name. |
static void |
unbindThread(java.lang.Object name)
Unbinds a naming context from the currently executing thread. |
static void |
unbindThread(java.lang.Object name,
java.lang.Object token)
Unbinds a naming context from the currently executing thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected static StringManager sm
Constructor Detail |
---|
public ContextBindings()
Method Detail |
---|
public static void bindContext(java.lang.Object name, javax.naming.Context context)
name.
name
- Name of the contextcontext
- Associated naming context instancepublic static void bindContext(java.lang.Object name, javax.naming.Context context, java.lang.Object token)
name.
name
- Name of the contextcontext
- Associated naming context instancetoken
- Security token associated with the contextpublic static void unbindContext(java.lang.Object name)
name
- Name of the contextpublic static void unbindContext(java.lang.Object name, java.lang.Object token)
name
- Name of the contexttoken
- Security tokenpublic static void bindThread(java.lang.Object name) throws javax.naming.NamingException
name
must have been previously bound to a
NamingContext
using
bindContext(Object, Context)
; otherwise a
NamingException
is thrown. Overwrites any existing
binding for the currently executing thread.
name
- Name of the context
javax.naming.NamingException
- if name
is not bound
to a contextpublic static void bindThread(java.lang.Object name, java.lang.Object token) throws javax.naming.NamingException
name
must have been previously bound to a
NamingContext
using
bindContext(Object, Context, Object)
; otherwise a
NamingException
is thrown. Checks the security token first
and does nothing if the check fails. Overwrites any existing
binding for the currently executing thread.
name
- Name of the contexttoken
- Security token
javax.naming.NamingException
- if name
is not bound
to a contextpublic static void unbindThread(java.lang.Object name)
name
is not bound to a context.
name
- Name of the contextpublic static void unbindThread(java.lang.Object name, java.lang.Object token)
name
is not bound to a context.
name
- Name of the contexttoken
- Security tokenpublic static javax.naming.Context getThread() throws javax.naming.NamingException
NamingException
if the current thread is not bound
to a context.
javax.naming.NamingException
- if the current thread is not boundbindThread(Object)
public static boolean isThreadBound()
public static void bindClassLoader(java.lang.Object name) throws javax.naming.NamingException
name
must have been previously
bound to a NamingContext
using
bindContext(Object, Context, Object)
; otherwise a
NamingException
is thrown.
Note: this method does not overwrite existing bindings. If the ClassLoader is already bound to a context, activating this method with a new context name does nothing.
name
- Name of the context
javax.naming.NamingException
- if the current thread is not bound
java.lang.SecurityException
- if a security manager exists and its
checkPermission
method doesn't allow getting the context
ClassLoaderpublic static void bindClassLoader(java.lang.Object name, java.lang.Object token) throws javax.naming.NamingException
name
must have been previously
bound to a NamingContext
using
bindContext(Object, Context, Object)
; otherwise a
NamingException
is thrown. Checks the security token
and does nothing if the check fails.
Note: this method does not overwrite existing bindings. If the ClassLoader is already bound to a context, activating this method with a new context name does nothing.
name
- Name of the contexttoken
- Security token associated with the name
javax.naming.NamingException
- if the current thread is not bound
java.lang.SecurityException
- if a security manager exists and its
checkPermission
method doesn't allow getting the context
ClassLoaderpublic static void bindClassLoader(java.lang.Object name, java.lang.Object token, java.lang.ClassLoader classLoader) throws javax.naming.NamingException
name
must have been previously bound to a NamingContext
using
bindContext(Object, Context, Object)
; otherwise a
NamingException
is thrown. Checks the security token
and does nothing if the check fails.
Note: this method does not overwrite existing bindings. If the ClassLoader is already bound to a context, activating this method with a new context name does nothing.
name
- Name of the contexttoken
- Security tokenclassLoader
- ClassLoader to bind
javax.naming.NamingException
- if the name is not bound to a contextpublic static void unbindClassLoader(java.lang.Object name)
name
- Name of the context
java.lang.SecurityException
- if a security manager exists and its
checkPermission
method doesn't allow getting the context
ClassLoaderpublic static void unbindClassLoader(java.lang.Object name, java.lang.Object token)
name
- Name of the contexttoken
- Security token
java.lang.SecurityException
- if a security manager exists and its
checkPermission
method doesn't allow getting the context
ClassLoaderpublic static void unbindClassLoader(java.lang.Object name, java.lang.Object token, java.lang.ClassLoader classLoader)
name
- Name of the contexttoken
- Security tokenclassLoader
- ClassLoader to unbindpublic static javax.naming.Context getClassLoader() throws javax.naming.NamingException
NamingException
if no ClassLoader in the hierarchy is bound to a context.
javax.naming.NamingException
- if no bound ClassLoader is found
java.lang.SecurityException
- if a security manager exists and its
checkPermission
blocks access to a ClassLoaderbindClassLoader(Object)
public static boolean isClassLoaderBound()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |