Package org.apache.activemq.jndi
Class ReadOnlyContext
- java.lang.Object
-
- org.apache.activemq.jndi.ReadOnlyContext
-
- All Implemented Interfaces:
Serializable,Context
- Direct Known Subclasses:
LazyCreateContext
public class ReadOnlyContext extends Object implements Context, Serializable
A read-only Context This version assumes it and all its subcontext are read-only and any attempt to modify (e.g. through bind) will result in an OperationNotSupportedException. Each Context in the tree builds a cache of the entries in all sub-contexts to optimise the performance of lookup.This implementation is intended to optimise the performance of lookup(String) to about the level of a HashMap get. It has been observed that the scheme resolution phase performed by the JVM takes considerably longer, so for optimum performance lookups should be coded like:
Context componentContext = (Context)new InitialContext().lookup("java:comp"); String envEntry = (String) componentContext.lookup("env/myEntry"); String envEntry2 = (String) componentContext.lookup("env/myEntry2");$Date: 2005/08/27 03:52:39 $- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Map<String,Object>bindingsprotected Hashtable<String,Object>environmentprotected static NameParserNAME_PARSERstatic StringSEPARATORprotected Map<String,Object>treeBindings-
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
-
-
Constructor Summary
Constructors Modifier Constructor Description ReadOnlyContext()ReadOnlyContext(Hashtable env)ReadOnlyContext(Hashtable environment, Map<String,Object> bindings)ReadOnlyContext(Hashtable environment, Map bindings, String nameInNamespace)protectedReadOnlyContext(ReadOnlyContext clone, Hashtable env)protectedReadOnlyContext(ReadOnlyContext clone, Hashtable<String,Object> env, String nameInNamespace)
-
Method Summary
-
-
-
Field Detail
-
SEPARATOR
public static final String SEPARATOR
- See Also:
- Constant Field Values
-
NAME_PARSER
protected static final NameParser NAME_PARSER
-
-
Constructor Detail
-
ReadOnlyContext
public ReadOnlyContext()
-
ReadOnlyContext
public ReadOnlyContext(Hashtable env)
-
ReadOnlyContext
public ReadOnlyContext(Hashtable environment, Map bindings, String nameInNamespace)
-
ReadOnlyContext
protected ReadOnlyContext(ReadOnlyContext clone, Hashtable env)
-
ReadOnlyContext
protected ReadOnlyContext(ReadOnlyContext clone, Hashtable<String,Object> env, String nameInNamespace)
-
-
Method Detail
-
freeze
public void freeze()
-
internalBind
protected Map<String,Object> internalBind(String name, Object value) throws NamingException
internalBind is intended for use only during setup or possibly by suitably synchronized superclasses. It binds every possible lookup into a map in each context. To do this, each context strips off one name segment and if necessary creates a new context for it. Then it asks that context to bind the remaining name. It returns a map containing all the bindings from the next context, plus the context it just created (if it in fact created it). (the names are suitably extended by the segment originally lopped off).- Parameters:
name-value-- Returns:
- Throws:
NamingException
-
newContext
protected ReadOnlyContext newContext()
-
addToEnvironment
public Object addToEnvironment(String propName, Object propVal) throws NamingException
- Specified by:
addToEnvironmentin interfaceContext- Throws:
NamingException
-
getEnvironment
public Hashtable<String,Object> getEnvironment() throws NamingException
- Specified by:
getEnvironmentin interfaceContext- Throws:
NamingException
-
removeFromEnvironment
public Object removeFromEnvironment(String propName) throws NamingException
- Specified by:
removeFromEnvironmentin interfaceContext- Throws:
NamingException
-
lookup
public Object lookup(String name) throws NamingException
- Specified by:
lookupin interfaceContext- Throws:
NamingException
-
lookup
public Object lookup(Name name) throws NamingException
- Specified by:
lookupin interfaceContext- Throws:
NamingException
-
lookupLink
public Object lookupLink(String name) throws NamingException
- Specified by:
lookupLinkin interfaceContext- Throws:
NamingException
-
composeName
public Name composeName(Name name, Name prefix) throws NamingException
- Specified by:
composeNamein interfaceContext- Throws:
NamingException
-
composeName
public String composeName(String name, String prefix) throws NamingException
- Specified by:
composeNamein interfaceContext- Throws:
NamingException
-
list
public NamingEnumeration list(String name) throws NamingException
- Specified by:
listin interfaceContext- Throws:
NamingException
-
listBindings
public NamingEnumeration listBindings(String name) throws NamingException
- Specified by:
listBindingsin interfaceContext- Throws:
NamingException
-
lookupLink
public Object lookupLink(Name name) throws NamingException
- Specified by:
lookupLinkin interfaceContext- Throws:
NamingException
-
list
public NamingEnumeration list(Name name) throws NamingException
- Specified by:
listin interfaceContext- Throws:
NamingException
-
listBindings
public NamingEnumeration listBindings(Name name) throws NamingException
- Specified by:
listBindingsin interfaceContext- Throws:
NamingException
-
bind
public void bind(Name name, Object obj) throws NamingException
- Specified by:
bindin interfaceContext- Throws:
NamingException
-
bind
public void bind(String name, Object obj) throws NamingException
- Specified by:
bindin interfaceContext- Throws:
NamingException
-
close
public void close() throws NamingException- Specified by:
closein interfaceContext- Throws:
NamingException
-
createSubcontext
public Context createSubcontext(Name name) throws NamingException
- Specified by:
createSubcontextin interfaceContext- Throws:
NamingException
-
createSubcontext
public Context createSubcontext(String name) throws NamingException
- Specified by:
createSubcontextin interfaceContext- Throws:
NamingException
-
destroySubcontext
public void destroySubcontext(Name name) throws NamingException
- Specified by:
destroySubcontextin interfaceContext- Throws:
NamingException
-
destroySubcontext
public void destroySubcontext(String name) throws NamingException
- Specified by:
destroySubcontextin interfaceContext- Throws:
NamingException
-
getNameInNamespace
public String getNameInNamespace() throws NamingException
- Specified by:
getNameInNamespacein interfaceContext- Throws:
NamingException
-
getNameParser
public NameParser getNameParser(Name name) throws NamingException
- Specified by:
getNameParserin interfaceContext- Throws:
NamingException
-
getNameParser
public NameParser getNameParser(String name) throws NamingException
- Specified by:
getNameParserin interfaceContext- Throws:
NamingException
-
rebind
public void rebind(Name name, Object obj) throws NamingException
- Specified by:
rebindin interfaceContext- Throws:
NamingException
-
rebind
public void rebind(String name, Object obj) throws NamingException
- Specified by:
rebindin interfaceContext- Throws:
NamingException
-
rename
public void rename(Name oldName, Name newName) throws NamingException
- Specified by:
renamein interfaceContext- Throws:
NamingException
-
rename
public void rename(String oldName, String newName) throws NamingException
- Specified by:
renamein interfaceContext- Throws:
NamingException
-
unbind
public void unbind(Name name) throws NamingException
- Specified by:
unbindin interfaceContext- Throws:
NamingException
-
unbind
public void unbind(String name) throws NamingException
- Specified by:
unbindin interfaceContext- Throws:
NamingException
-
-