Package org.apache.activemq.artemis.jndi
Class ReadOnlyContext
- java.lang.Object
-
- org.apache.activemq.artemis.jndi.ReadOnlyContext
-
- All Implemented Interfaces:
java.io.Serializable
,javax.naming.Context
- Direct Known Subclasses:
LazyCreateContext
public class ReadOnlyContext extends java.lang.Object implements javax.naming.Context, java.io.Serializable
A read-only ContextThis 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");
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.Map<java.lang.String,java.lang.Object>
bindings
protected java.util.Hashtable<java.lang.String,java.lang.Object>
environment
protected static javax.naming.NameParser
NAME_PARSER
static java.lang.String
SEPARATOR
protected java.util.Map<java.lang.String,java.lang.Object>
treeBindings
-
Constructor Summary
Constructors Modifier Constructor Description ReadOnlyContext()
ReadOnlyContext(java.util.Hashtable env)
ReadOnlyContext(java.util.Hashtable environment, java.util.Map<java.lang.String,java.lang.Object> bindings)
ReadOnlyContext(java.util.Hashtable environment, java.util.Map<java.lang.String,java.lang.Object> bindings, java.lang.String nameInNamespace)
protected
ReadOnlyContext(ReadOnlyContext clone, java.util.Hashtable env)
protected
ReadOnlyContext(ReadOnlyContext clone, java.util.Hashtable<java.lang.String,java.lang.Object> env, java.lang.String nameInNamespace)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.Object
addToEnvironment(java.lang.String propName, java.lang.Object propVal)
void
bind(java.lang.String name, java.lang.Object obj)
void
bind(javax.naming.Name name, java.lang.Object obj)
void
close()
java.lang.String
composeName(java.lang.String name, java.lang.String prefix)
javax.naming.Name
composeName(javax.naming.Name name, javax.naming.Name prefix)
javax.naming.Context
createSubcontext(java.lang.String name)
javax.naming.Context
createSubcontext(javax.naming.Name name)
void
destroySubcontext(java.lang.String name)
void
destroySubcontext(javax.naming.Name name)
void
freeze()
java.util.Hashtable<java.lang.String,java.lang.Object>
getEnvironment()
java.lang.String
getNameInNamespace()
javax.naming.NameParser
getNameParser(java.lang.String name)
javax.naming.NameParser
getNameParser(javax.naming.Name name)
protected java.util.Map<java.lang.String,java.lang.Object>
internalBind(java.lang.String name, java.lang.Object value)
internalBind is intended for use only during setup or possibly by suitably synchronized superclasses.javax.naming.NamingEnumeration<javax.naming.NameClassPair>
list(java.lang.String name)
javax.naming.NamingEnumeration<javax.naming.NameClassPair>
list(javax.naming.Name name)
javax.naming.NamingEnumeration<javax.naming.Binding>
listBindings(java.lang.String name)
javax.naming.NamingEnumeration<javax.naming.Binding>
listBindings(javax.naming.Name name)
java.lang.Object
lookup(java.lang.String name)
java.lang.Object
lookup(javax.naming.Name name)
java.lang.Object
lookupLink(java.lang.String name)
java.lang.Object
lookupLink(javax.naming.Name name)
protected ReadOnlyContext
newContext()
void
rebind(java.lang.String name, java.lang.Object obj)
void
rebind(javax.naming.Name name, java.lang.Object obj)
java.lang.Object
removeFromEnvironment(java.lang.String propName)
void
rename(java.lang.String oldName, java.lang.String newName)
void
rename(javax.naming.Name oldName, javax.naming.Name newName)
void
unbind(java.lang.String name)
void
unbind(javax.naming.Name name)
-
-
-
Field Detail
-
SEPARATOR
public static final java.lang.String SEPARATOR
- See Also:
- Constant Field Values
-
NAME_PARSER
protected static final javax.naming.NameParser NAME_PARSER
-
environment
protected final java.util.Hashtable<java.lang.String,java.lang.Object> environment
-
bindings
protected final java.util.Map<java.lang.String,java.lang.Object> bindings
-
treeBindings
protected final java.util.Map<java.lang.String,java.lang.Object> treeBindings
-
-
Constructor Detail
-
ReadOnlyContext
public ReadOnlyContext()
-
ReadOnlyContext
public ReadOnlyContext(java.util.Hashtable env)
-
ReadOnlyContext
public ReadOnlyContext(java.util.Hashtable environment, java.util.Map<java.lang.String,java.lang.Object> bindings)
-
ReadOnlyContext
public ReadOnlyContext(java.util.Hashtable environment, java.util.Map<java.lang.String,java.lang.Object> bindings, java.lang.String nameInNamespace)
-
ReadOnlyContext
protected ReadOnlyContext(ReadOnlyContext clone, java.util.Hashtable env)
-
ReadOnlyContext
protected ReadOnlyContext(ReadOnlyContext clone, java.util.Hashtable<java.lang.String,java.lang.Object> env, java.lang.String nameInNamespace)
-
-
Method Detail
-
freeze
public void freeze()
-
internalBind
protected java.util.Map<java.lang.String,java.lang.Object> internalBind(java.lang.String name, java.lang.Object value) throws javax.naming.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:
javax.naming.NamingException
-
newContext
protected ReadOnlyContext newContext()
-
addToEnvironment
public java.lang.Object addToEnvironment(java.lang.String propName, java.lang.Object propVal) throws javax.naming.NamingException
- Specified by:
addToEnvironment
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
getEnvironment
public java.util.Hashtable<java.lang.String,java.lang.Object> getEnvironment() throws javax.naming.NamingException
- Specified by:
getEnvironment
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
removeFromEnvironment
public java.lang.Object removeFromEnvironment(java.lang.String propName) throws javax.naming.NamingException
- Specified by:
removeFromEnvironment
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
lookup
public java.lang.Object lookup(java.lang.String name) throws javax.naming.NamingException
- Specified by:
lookup
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
lookup
public java.lang.Object lookup(javax.naming.Name name) throws javax.naming.NamingException
- Specified by:
lookup
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
lookupLink
public java.lang.Object lookupLink(java.lang.String name) throws javax.naming.NamingException
- Specified by:
lookupLink
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
composeName
public javax.naming.Name composeName(javax.naming.Name name, javax.naming.Name prefix) throws javax.naming.NamingException
- Specified by:
composeName
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
composeName
public java.lang.String composeName(java.lang.String name, java.lang.String prefix) throws javax.naming.NamingException
- Specified by:
composeName
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
list
public javax.naming.NamingEnumeration<javax.naming.NameClassPair> list(java.lang.String name) throws javax.naming.NamingException
- Specified by:
list
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
listBindings
public javax.naming.NamingEnumeration<javax.naming.Binding> listBindings(java.lang.String name) throws javax.naming.NamingException
- Specified by:
listBindings
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
lookupLink
public java.lang.Object lookupLink(javax.naming.Name name) throws javax.naming.NamingException
- Specified by:
lookupLink
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
list
public javax.naming.NamingEnumeration<javax.naming.NameClassPair> list(javax.naming.Name name) throws javax.naming.NamingException
- Specified by:
list
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
listBindings
public javax.naming.NamingEnumeration<javax.naming.Binding> listBindings(javax.naming.Name name) throws javax.naming.NamingException
- Specified by:
listBindings
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
bind
public void bind(javax.naming.Name name, java.lang.Object obj) throws javax.naming.NamingException
- Specified by:
bind
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
bind
public void bind(java.lang.String name, java.lang.Object obj) throws javax.naming.NamingException
- Specified by:
bind
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
close
public void close() throws javax.naming.NamingException
- Specified by:
close
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
createSubcontext
public javax.naming.Context createSubcontext(javax.naming.Name name) throws javax.naming.NamingException
- Specified by:
createSubcontext
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
createSubcontext
public javax.naming.Context createSubcontext(java.lang.String name) throws javax.naming.NamingException
- Specified by:
createSubcontext
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
destroySubcontext
public void destroySubcontext(javax.naming.Name name) throws javax.naming.NamingException
- Specified by:
destroySubcontext
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
destroySubcontext
public void destroySubcontext(java.lang.String name) throws javax.naming.NamingException
- Specified by:
destroySubcontext
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
getNameInNamespace
public java.lang.String getNameInNamespace() throws javax.naming.NamingException
- Specified by:
getNameInNamespace
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
getNameParser
public javax.naming.NameParser getNameParser(javax.naming.Name name) throws javax.naming.NamingException
- Specified by:
getNameParser
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
getNameParser
public javax.naming.NameParser getNameParser(java.lang.String name) throws javax.naming.NamingException
- Specified by:
getNameParser
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
rebind
public void rebind(javax.naming.Name name, java.lang.Object obj) throws javax.naming.NamingException
- Specified by:
rebind
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
rebind
public void rebind(java.lang.String name, java.lang.Object obj) throws javax.naming.NamingException
- Specified by:
rebind
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
rename
public void rename(javax.naming.Name oldName, javax.naming.Name newName) throws javax.naming.NamingException
- Specified by:
rename
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
rename
public void rename(java.lang.String oldName, java.lang.String newName) throws javax.naming.NamingException
- Specified by:
rename
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
unbind
public void unbind(javax.naming.Name name) throws javax.naming.NamingException
- Specified by:
unbind
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
unbind
public void unbind(java.lang.String name) throws javax.naming.NamingException
- Specified by:
unbind
in interfacejavax.naming.Context
- Throws:
javax.naming.NamingException
-
-