public class ReadOnlyContext extends Object implements Context, Serializable
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");
| Modifier and Type | Field and Description |
|---|---|
protected Map<String,Object> |
bindings |
protected Hashtable<String,Object> |
environment |
protected static NameParser |
NAME_PARSER |
static String |
SEPARATOR |
protected Map<String,Object> |
treeBindings |
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| Modifier | Constructor and Description |
|---|---|
|
ReadOnlyContext() |
|
ReadOnlyContext(Hashtable env) |
|
ReadOnlyContext(Hashtable environment,
Map<String,Object> bindings) |
|
ReadOnlyContext(Hashtable environment,
Map<String,Object> bindings,
String nameInNamespace) |
protected |
ReadOnlyContext(ReadOnlyContext clone,
Hashtable env) |
protected |
ReadOnlyContext(ReadOnlyContext clone,
Hashtable<String,Object> env,
String nameInNamespace) |
public static final String SEPARATOR
protected static final NameParser NAME_PARSER
public ReadOnlyContext()
public ReadOnlyContext(Hashtable env)
public ReadOnlyContext(Hashtable environment, Map<String,Object> bindings, String nameInNamespace)
protected ReadOnlyContext(ReadOnlyContext clone, Hashtable env)
protected ReadOnlyContext(ReadOnlyContext clone, Hashtable<String,Object> env, String nameInNamespace)
public void freeze()
protected Map<String,Object> internalBind(String name, Object value) throws NamingException
name - value - NamingExceptionprotected ReadOnlyContext newContext()
public Object addToEnvironment(String propName, Object propVal) throws NamingException
addToEnvironment in interface ContextNamingExceptionpublic Hashtable<String,Object> getEnvironment() throws NamingException
getEnvironment in interface ContextNamingExceptionpublic Object removeFromEnvironment(String propName) throws NamingException
removeFromEnvironment in interface ContextNamingExceptionpublic Object lookup(String name) throws NamingException
lookup in interface ContextNamingExceptionpublic Object lookup(Name name) throws NamingException
lookup in interface ContextNamingExceptionpublic Object lookupLink(String name) throws NamingException
lookupLink in interface ContextNamingExceptionpublic Name composeName(Name name, Name prefix) throws NamingException
composeName in interface ContextNamingExceptionpublic String composeName(String name, String prefix) throws NamingException
composeName in interface ContextNamingExceptionpublic NamingEnumeration<NameClassPair> list(String name) throws NamingException
list in interface ContextNamingExceptionpublic NamingEnumeration<Binding> listBindings(String name) throws NamingException
listBindings in interface ContextNamingExceptionpublic Object lookupLink(Name name) throws NamingException
lookupLink in interface ContextNamingExceptionpublic NamingEnumeration<NameClassPair> list(Name name) throws NamingException
list in interface ContextNamingExceptionpublic NamingEnumeration<Binding> listBindings(Name name) throws NamingException
listBindings in interface ContextNamingExceptionpublic void bind(Name name, Object obj) throws NamingException
bind in interface ContextNamingExceptionpublic void bind(String name, Object obj) throws NamingException
bind in interface ContextNamingExceptionpublic void close()
throws NamingException
close in interface ContextNamingExceptionpublic Context createSubcontext(Name name) throws NamingException
createSubcontext in interface ContextNamingExceptionpublic Context createSubcontext(String name) throws NamingException
createSubcontext in interface ContextNamingExceptionpublic void destroySubcontext(Name name) throws NamingException
destroySubcontext in interface ContextNamingExceptionpublic void destroySubcontext(String name) throws NamingException
destroySubcontext in interface ContextNamingExceptionpublic String getNameInNamespace() throws NamingException
getNameInNamespace in interface ContextNamingExceptionpublic NameParser getNameParser(Name name) throws NamingException
getNameParser in interface ContextNamingExceptionpublic NameParser getNameParser(String name) throws NamingException
getNameParser in interface ContextNamingExceptionpublic void rebind(Name name, Object obj) throws NamingException
rebind in interface ContextNamingExceptionpublic void rebind(String name, Object obj) throws NamingException
rebind in interface ContextNamingExceptionpublic void rename(Name oldName, Name newName) throws NamingException
rename in interface ContextNamingExceptionpublic void rename(String oldName, String newName) throws NamingException
rename in interface ContextNamingExceptionpublic void unbind(Name name) throws NamingException
unbind in interface ContextNamingExceptionpublic void unbind(String name) throws NamingException
unbind in interface ContextNamingExceptionCopyright © 2017 JBoss by Red Hat. All rights reserved.