Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.activemq.jndi
Class ReadOnlyContext  view ReadOnlyContext download ReadOnlyContext.java

java.lang.Object
  extended byorg.activemq.jndi.ReadOnlyContext
All Implemented Interfaces:
javax.naming.Context, java.io.Serializable
Direct Known Subclasses:
LazyCreateContext

public class ReadOnlyContext
extends java.lang.Object
implements javax.naming.Context, java.io.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");

Version:
$Revision: 1.1.1.1 $ $Date: 2005/03/11 21:14:27 $

Nested Class Summary
private  class ReadOnlyContext.ListBindingEnumeration
           
private  class ReadOnlyContext.ListEnumeration
           
private  class ReadOnlyContext.LocalNamingEnumeration
           
 
Field Summary
protected  java.util.Map bindings
           
protected  java.util.Hashtable environment
           
private  boolean frozen
           
private  java.lang.String nameInNamespace
           
protected static javax.naming.NameParser nameParser
           
static java.lang.String SEPARATOR
           
private static long serialVersionUID
           
protected  java.util.Map 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
  ReadOnlyContext()
           
  ReadOnlyContext(java.util.Hashtable env)
           
  ReadOnlyContext(java.util.Hashtable environment, java.util.Map bindings)
           
  ReadOnlyContext(java.util.Hashtable environment, java.util.Map bindings, java.lang.String nameInNamespace)
           
protected ReadOnlyContext(ReadOnlyContext clone, java.util.Hashtable env)
           
protected ReadOnlyContext(ReadOnlyContext clone, java.util.Hashtable env, java.lang.String nameInNamespace)
           
 
Method Summary
 java.lang.Object addToEnvironment(java.lang.String propName, java.lang.Object propVal)
           
 void bind(javax.naming.Name name, java.lang.Object obj)
           
 void bind(java.lang.String name, java.lang.Object obj)
           
 void close()
           
 javax.naming.Name composeName(javax.naming.Name name, javax.naming.Name prefix)
           
 java.lang.String composeName(java.lang.String name, java.lang.String prefix)
           
 javax.naming.Context createSubcontext(javax.naming.Name name)
           
 javax.naming.Context createSubcontext(java.lang.String name)
           
 void destroySubcontext(javax.naming.Name name)
           
 void destroySubcontext(java.lang.String name)
           
 void freeze()
           
 java.util.Hashtable getEnvironment()
           
 java.lang.String getNameInNamespace()
           
 javax.naming.NameParser getNameParser(javax.naming.Name name)
           
 javax.naming.NameParser getNameParser(java.lang.String name)
           
protected  java.util.Map internalBind(java.lang.String name, java.lang.Object value)
          internalBind is intended for use only during setup or possibly by suitably synchronized superclasses.
(package private)  boolean isFrozen()
           
 javax.naming.NamingEnumeration list(javax.naming.Name name)
           
 javax.naming.NamingEnumeration list(java.lang.String name)
           
 javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
           
 javax.naming.NamingEnumeration listBindings(java.lang.String name)
           
 java.lang.Object lookup(javax.naming.Name name)
           
 java.lang.Object lookup(java.lang.String name)
           
 java.lang.Object lookupLink(javax.naming.Name name)
           
 java.lang.Object lookupLink(java.lang.String name)
           
protected  ReadOnlyContext newContext()
           
 void rebind(javax.naming.Name name, java.lang.Object obj)
           
 void rebind(java.lang.String name, java.lang.Object obj)
           
 java.lang.Object removeFromEnvironment(java.lang.String propName)
           
 void rename(javax.naming.Name oldName, javax.naming.Name newName)
           
 void rename(java.lang.String oldName, java.lang.String newName)
           
 void unbind(javax.naming.Name name)
           
 void unbind(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values

nameParser

protected static final javax.naming.NameParser nameParser

environment

protected final java.util.Hashtable environment

bindings

protected final java.util.Map bindings

treeBindings

protected final java.util.Map treeBindings

frozen

private boolean frozen

nameInNamespace

private java.lang.String nameInNamespace

SEPARATOR

public static final java.lang.String SEPARATOR
See Also:
Constant Field Values
Constructor Detail

ReadOnlyContext

public ReadOnlyContext()

ReadOnlyContext

public ReadOnlyContext(java.util.Hashtable env)

ReadOnlyContext

public ReadOnlyContext(java.util.Hashtable environment,
                       java.util.Map bindings)

ReadOnlyContext

public ReadOnlyContext(java.util.Hashtable environment,
                       java.util.Map bindings,
                       java.lang.String nameInNamespace)

ReadOnlyContext

protected ReadOnlyContext(ReadOnlyContext clone,
                          java.util.Hashtable env)

ReadOnlyContext

protected ReadOnlyContext(ReadOnlyContext clone,
                          java.util.Hashtable env,
                          java.lang.String nameInNamespace)
Method Detail

freeze

public void freeze()

isFrozen

boolean isFrozen()

internalBind

protected java.util.Map 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).


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 interface javax.naming.Context

getEnvironment

public java.util.Hashtable getEnvironment()
                                   throws javax.naming.NamingException
Specified by:
getEnvironment in interface javax.naming.Context

removeFromEnvironment

public java.lang.Object removeFromEnvironment(java.lang.String propName)
                                       throws javax.naming.NamingException
Specified by:
removeFromEnvironment in interface javax.naming.Context

lookup

public java.lang.Object lookup(java.lang.String name)
                        throws javax.naming.NamingException
Specified by:
lookup in interface javax.naming.Context

lookup

public java.lang.Object lookup(javax.naming.Name name)
                        throws javax.naming.NamingException
Specified by:
lookup in interface javax.naming.Context

lookupLink

public java.lang.Object lookupLink(java.lang.String name)
                            throws javax.naming.NamingException
Specified by:
lookupLink in interface javax.naming.Context

composeName

public javax.naming.Name composeName(javax.naming.Name name,
                                     javax.naming.Name prefix)
                              throws javax.naming.NamingException
Specified by:
composeName in interface javax.naming.Context

composeName

public java.lang.String composeName(java.lang.String name,
                                    java.lang.String prefix)
                             throws javax.naming.NamingException
Specified by:
composeName in interface javax.naming.Context

list

public javax.naming.NamingEnumeration list(java.lang.String name)
                                    throws javax.naming.NamingException
Specified by:
list in interface javax.naming.Context

listBindings

public javax.naming.NamingEnumeration listBindings(java.lang.String name)
                                            throws javax.naming.NamingException
Specified by:
listBindings in interface javax.naming.Context

lookupLink

public java.lang.Object lookupLink(javax.naming.Name name)
                            throws javax.naming.NamingException
Specified by:
lookupLink in interface javax.naming.Context

list

public javax.naming.NamingEnumeration list(javax.naming.Name name)
                                    throws javax.naming.NamingException
Specified by:
list in interface javax.naming.Context

listBindings

public javax.naming.NamingEnumeration listBindings(javax.naming.Name name)
                                            throws javax.naming.NamingException
Specified by:
listBindings in interface javax.naming.Context

bind

public void bind(javax.naming.Name name,
                 java.lang.Object obj)
          throws javax.naming.NamingException
Specified by:
bind in interface javax.naming.Context

bind

public void bind(java.lang.String name,
                 java.lang.Object obj)
          throws javax.naming.NamingException
Specified by:
bind in interface javax.naming.Context

close

public void close()
           throws javax.naming.NamingException
Specified by:
close in interface javax.naming.Context

createSubcontext

public javax.naming.Context createSubcontext(javax.naming.Name name)
                                      throws javax.naming.NamingException
Specified by:
createSubcontext in interface javax.naming.Context

createSubcontext

public javax.naming.Context createSubcontext(java.lang.String name)
                                      throws javax.naming.NamingException
Specified by:
createSubcontext in interface javax.naming.Context

destroySubcontext

public void destroySubcontext(javax.naming.Name name)
                       throws javax.naming.NamingException
Specified by:
destroySubcontext in interface javax.naming.Context

destroySubcontext

public void destroySubcontext(java.lang.String name)
                       throws javax.naming.NamingException
Specified by:
destroySubcontext in interface javax.naming.Context

getNameInNamespace

public java.lang.String getNameInNamespace()
                                    throws javax.naming.NamingException
Specified by:
getNameInNamespace in interface javax.naming.Context

getNameParser

public javax.naming.NameParser getNameParser(javax.naming.Name name)
                                      throws javax.naming.NamingException
Specified by:
getNameParser in interface javax.naming.Context

getNameParser

public javax.naming.NameParser getNameParser(java.lang.String name)
                                      throws javax.naming.NamingException
Specified by:
getNameParser in interface javax.naming.Context

rebind

public void rebind(javax.naming.Name name,
                   java.lang.Object obj)
            throws javax.naming.NamingException
Specified by:
rebind in interface javax.naming.Context

rebind

public void rebind(java.lang.String name,
                   java.lang.Object obj)
            throws javax.naming.NamingException
Specified by:
rebind in interface javax.naming.Context

rename

public void rename(javax.naming.Name oldName,
                   javax.naming.Name newName)
            throws javax.naming.NamingException
Specified by:
rename in interface javax.naming.Context

rename

public void rename(java.lang.String oldName,
                   java.lang.String newName)
            throws javax.naming.NamingException
Specified by:
rename in interface javax.naming.Context

unbind

public void unbind(javax.naming.Name name)
            throws javax.naming.NamingException
Specified by:
unbind in interface javax.naming.Context

unbind

public void unbind(java.lang.String name)
            throws javax.naming.NamingException
Specified by:
unbind in interface javax.naming.Context