* concurrently should synchronize amongst themselves and provide the
* necessary locking.
*
* @author Rosanna Lee
* @author Scott Seligman
* @version 1.15 06/01/06
*
* @see Context
* @see NamingManager#setInitialContextFactoryBuilder
* NamingManager.setInitialContextFactoryBuilder
* @since JNDI 1.1 / Java 2 Platform, Standard Edition, v 1.3
*/
public class InitialContext implements Context {
/**
* The environment associated with this InitialContext.
* It is initialized to null and is updated by the constructor
* that accepts an environment or by the <tt>init()</tt> method.
* @see #addToEnvironment
* @see #removeFromEnvironment
* @see #getEnvironment
*/
protected Hashtable<Object,Object> myProps = null;
/**
* Field holding the result of calling NamingManager.getInitialContext().
* It is set by getDefaultInitCtx() the first time getDefaultInitCtx()
* is called. Subsequent invocations of getDefaultInitCtx() return
* the value of defaultInitCtx.
* @see #getDefaultInitCtx
*/
protected Context defaultInitCtx = null;
/**
* Field indicating whether the initial context has been obtained
* by calling NamingManager.getInitialContext().
* If true, its result is in <code>defaultInitCtx</code>.
*/
protected boolean gotDefault = false;
/**
* Constructs an initial context with the option of not
* initializing it. This may be used by a constructor in
* a subclass when the value of the environment parameter
* is not yet known at the time the <tt>InitialContext</tt>
* constructor is called. The subclass's constructor will
* call this constructor, compute the value of the environment,
* and then call <tt>init()</tt> before returning.
*
* @param lazy
* true means do not initialize the initial context; false
* is equivalent to calling <tt>new InitialContext()</tt>
* @throws NamingException if a naming exception is encountered
*
* @see #init(Hashtable)
* @since 1.3
*/
protected InitialContext(boolean lazy) throws NamingException {
if (!lazy) {
init(null);
}
}
/**
* Constructs an initial context.
* No environment properties are supplied.
* Equivalent to <tt>new InitialContext(null)</tt>.
*
* @throws NamingException if a naming exception is encountered
*
* @see #InitialContext(Hashtable)
*/
public InitialContext() throws NamingException {
init(null);
}
/**
* Constructs an initial context using the supplied environment.
* Environment properties are discussed in the class description.
*
* <p> This constructor will not modify <tt>environment</tt>
* or save a reference to it, but may save a clone.
*
* @param environment
* environment used to create the initial context.
* Null indicates an empty environment.
*
* @throws NamingException if a naming exception is encountered
*/
public InitialContext(Hashtable<?,?> environment)
throws NamingException
{
if (environment != null) {
environment = (Hashtable)environment.clone();
}
init(environment);
}
/**
=2= |