Class ReadOnlyContext

java.lang.Object
org.apache.activemq.artemis.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(Object). 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: