org.rhq.jndi.context
Class URLPreferringContextDecorator
java.lang.Object
org.rhq.jndi.context.URLPreferringContextDecorator
- All Implemented Interfaces:
- Serializable, Context, ContextDecorator
- Direct Known Subclasses:
- URLPreferringDirContextDecorator, URLPreferringEventContextDecorator
public class URLPreferringContextDecorator
- extends Object
- implements Context, ContextDecorator, Serializable
This is a wrapper class around another Context implementation that
prefers to use an URL context for some operation if the JNDI name contains
a scheme rather than the original. This is the behavior of InitialContext
which we need to restore in the contexts created by the AccessCheckingInitialContextFactoryBuilder
(which an InitialContext uses exclusively if the builder is set).
This is important because RHQ server has its own initial context factory
builder that creates factories that in turn create contexts. If the default
InitialContext implementation was used, we'd never be able to lookup
scheme-based names because the default implementation of the InitialContext
always uses the default context of the builder if one is installed no matter
the scheme in the name.
The AccessCheckingInitialContextFactoryBuilder wraps the context returned
by the factory in an instance of this class and thus is restoring the original
intended behavior of the InitialContext. It looks at the name being looked
up (bound or whatever) and prefers to use the URL context factories if the name
contains the scheme (as does the InitialContext if no builder is installed).
If the name doesn't contain a scheme, the provided default context factory is used to
look up the name.
- Author:
- Lukas Krejci
- See Also:
- Serialized Form
| Fields inherited from interface javax.naming.Context |
APPLET, AUTHORITATIVE, BATCHSIZE, DNS_URL, INITIAL_CONTEXT_FACTORY, LANGUAGE, OBJECT_FACTORIES, PROVIDER_URL, REFERRAL, SECURITY_AUTHENTICATION, SECURITY_CREDENTIALS, SECURITY_PRINCIPAL, SECURITY_PROTOCOL, STATE_FACTORIES, URL_PKG_PREFIXES |
|
Method Summary |
Object |
addToEnvironment(String propName,
Object propVal)
|
void |
bind(Name name,
Object obj)
|
void |
bind(String name,
Object obj)
|
void |
close()
|
Name |
composeName(Name name,
Name prefix)
|
String |
composeName(String name,
String prefix)
|
Context |
createSubcontext(Name name)
|
Context |
createSubcontext(String name)
|
void |
destroySubcontext(Name name)
|
void |
destroySubcontext(String name)
|
boolean |
equals(Object o)
|
Hashtable<?,?> |
getEnvironment()
|
String |
getNameInNamespace()
|
NameParser |
getNameParser(Name name)
|
NameParser |
getNameParser(String name)
|
protected Context |
getOriginal()
|
protected Context |
getURLOrDefaultInitCtx(Name name)
|
protected Context |
getURLOrDefaultInitCtx(String name)
|
int |
hashCode()
|
void |
init(Context context)
|
NamingEnumeration<NameClassPair> |
list(Name name)
|
NamingEnumeration<NameClassPair> |
list(String name)
|
NamingEnumeration<Binding> |
listBindings(Name name)
|
NamingEnumeration<Binding> |
listBindings(String name)
|
Object |
lookup(Name name)
|
Object |
lookup(String name)
|
Object |
lookupLink(Name name)
|
Object |
lookupLink(String name)
|
void |
rebind(Name name,
Object obj)
|
void |
rebind(String name,
Object obj)
|
Object |
removeFromEnvironment(String propName)
|
void |
rename(Name oldName,
Name newName)
|
void |
rename(String oldName,
String newName)
|
void |
unbind(Name name)
|
void |
unbind(String name)
|
URLPreferringContextDecorator
public URLPreferringContextDecorator()
URLPreferringContextDecorator
public URLPreferringContextDecorator(Context ctx)
init
public void init(Context context)
- Specified by:
init in interface ContextDecorator
getOriginal
protected Context getOriginal()
throws NamingException
- Throws:
NamingException
getURLOrDefaultInitCtx
protected Context getURLOrDefaultInitCtx(Name name)
throws NamingException
- Throws:
NamingException
getURLOrDefaultInitCtx
protected Context getURLOrDefaultInitCtx(String name)
throws NamingException
- Throws:
NamingException
lookup
public Object lookup(Name name)
throws NamingException
- Specified by:
lookup in interface Context
- Throws:
NamingException
lookup
public Object lookup(String name)
throws NamingException
- Specified by:
lookup in interface Context
- Throws:
NamingException
bind
public void bind(Name name,
Object obj)
throws NamingException
- Specified by:
bind in interface Context
- Throws:
NamingException
bind
public void bind(String name,
Object obj)
throws NamingException
- Specified by:
bind in interface Context
- Throws:
NamingException
rebind
public void rebind(Name name,
Object obj)
throws NamingException
- Specified by:
rebind in interface Context
- Throws:
NamingException
rebind
public void rebind(String name,
Object obj)
throws NamingException
- Specified by:
rebind in interface Context
- Throws:
NamingException
unbind
public void unbind(Name name)
throws NamingException
- Specified by:
unbind in interface Context
- Throws:
NamingException
unbind
public void unbind(String name)
throws NamingException
- Specified by:
unbind in interface Context
- Throws:
NamingException
rename
public void rename(Name oldName,
Name newName)
throws NamingException
- Specified by:
rename in interface Context
- Throws:
NamingException
rename
public void rename(String oldName,
String newName)
throws NamingException
- Specified by:
rename in interface Context
- Throws:
NamingException
list
public NamingEnumeration<NameClassPair> list(Name name)
throws NamingException
- Specified by:
list in interface Context
- Throws:
NamingException
list
public NamingEnumeration<NameClassPair> list(String name)
throws NamingException
- Specified by:
list in interface Context
- Throws:
NamingException
listBindings
public NamingEnumeration<Binding> listBindings(Name name)
throws NamingException
- Specified by:
listBindings in interface Context
- Throws:
NamingException
listBindings
public NamingEnumeration<Binding> listBindings(String name)
throws NamingException
- Specified by:
listBindings in interface Context
- Throws:
NamingException
destroySubcontext
public void destroySubcontext(Name name)
throws NamingException
- Specified by:
destroySubcontext in interface Context
- Throws:
NamingException
destroySubcontext
public void destroySubcontext(String name)
throws NamingException
- Specified by:
destroySubcontext in interface Context
- Throws:
NamingException
createSubcontext
public Context createSubcontext(Name name)
throws NamingException
- Specified by:
createSubcontext in interface Context
- Throws:
NamingException
createSubcontext
public Context createSubcontext(String name)
throws NamingException
- Specified by:
createSubcontext in interface Context
- Throws:
NamingException
lookupLink
public Object lookupLink(Name name)
throws NamingException
- Specified by:
lookupLink in interface Context
- Throws:
NamingException
lookupLink
public Object lookupLink(String name)
throws NamingException
- Specified by:
lookupLink in interface Context
- Throws:
NamingException
getNameParser
public NameParser getNameParser(Name name)
throws NamingException
- Specified by:
getNameParser in interface Context
- Throws:
NamingException
getNameParser
public NameParser getNameParser(String name)
throws NamingException
- Specified by:
getNameParser in interface Context
- Throws:
NamingException
composeName
public Name composeName(Name name,
Name prefix)
throws NamingException
- Specified by:
composeName in interface Context
- Throws:
NamingException
composeName
public String composeName(String name,
String prefix)
throws NamingException
- Specified by:
composeName in interface Context
- Throws:
NamingException
addToEnvironment
public Object addToEnvironment(String propName,
Object propVal)
throws NamingException
- Specified by:
addToEnvironment in interface Context
- Throws:
NamingException
removeFromEnvironment
public Object removeFromEnvironment(String propName)
throws NamingException
- Specified by:
removeFromEnvironment in interface Context
- Throws:
NamingException
getEnvironment
public Hashtable<?,?> getEnvironment()
throws NamingException
- Specified by:
getEnvironment in interface Context
- Throws:
NamingException
close
public void close()
throws NamingException
- Specified by:
close in interface Context
- Throws:
NamingException
getNameInNamespace
public String getNameInNamespace()
throws NamingException
- Specified by:
getNameInNamespace in interface Context
- Throws:
NamingException
hashCode
public int hashCode()
- Overrides:
hashCode in class Object
equals
public boolean equals(Object o)
- Overrides:
equals in class Object
Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.