32 33 /** 34 * This class is the starting context for performing 35 * directory operations. The documentation in the class description 36 * of InitialContext (including those for synchronization) apply here. 37 * 38 * 39 * @author Rosanna Lee 40 * @author Scott Seligman 41 * 42 * @see javax.naming.InitialContext 43 * @since 1.3 44 */ 45 46 public class InitialDirContext extends InitialContext implements DirContext { 47 48 /** 49 * Constructs an initial DirContext with the option of not 50 * initializing it. This may be used by a constructor in 51 * a subclass when the value of the environment parameter 52 * is not yet known at the time the <tt>InitialDirContext</tt> 53 * constructor is called. The subclass's constructor will 54 * call this constructor, compute the value of the environment, 55 * and then call <tt>init()</tt> before returning. 56 * 57 * @param lazy 58 * true means do not initialize the initial DirContext; false 59 * is equivalent to calling <tt>new InitialDirContext()</tt> 60 * @throws NamingException if a naming exception is encountered 61 * 62 * @see InitialContext#init(Hashtable) 63 * @since 1.3 64 */ 65 protected InitialDirContext(boolean lazy) throws NamingException { 66 super(lazy); 67 } 68 69 /** 70 * Constructs an initial DirContext. 71 * No environment properties are supplied. 72 * Equivalent to <tt>new InitialDirContext(null)</tt>. 73 * 74 * @throws NamingException if a naming exception is encountered 75 * 76 * @see #InitialDirContext(Hashtable) 77 */ 78 public InitialDirContext() throws NamingException { 79 super(); 80 } 81 82 /** 83 * Constructs an initial DirContext using the supplied environment. 84 * Environment properties are discussed in the 85 * <tt>javax.naming.InitialContext</tt> class description. 86 * 87 * <p> This constructor will not modify <tt>environment</tt> 88 * or save a reference to it, but may save a clone. 89 * Caller should not modify mutable keys and values in 90 * <tt>environment</tt> after it has been passed to the constructor. 91 * 92 * @param environment 93 * environment used to create the initial DirContext. 94 * Null indicates an empty environment. 95 * 96 * @throws NamingException if a naming exception is encountered 97 */ 98 public InitialDirContext(Hashtable<?,?> environment) 99 throws NamingException 100 { 101 super(environment); 102 } 103 104 private DirContext getURLOrDefaultInitDirCtx(String name) 105 throws NamingException { 106 Context answer = getURLOrDefaultInitCtx(name); 107 if (!(answer instanceof DirContext)) { 108 if (answer == null) { 109 throw new NoInitialContextException(); 110 } else { | 32 33 /** 34 * This class is the starting context for performing 35 * directory operations. The documentation in the class description 36 * of InitialContext (including those for synchronization) apply here. 37 * 38 * 39 * @author Rosanna Lee 40 * @author Scott Seligman 41 * 42 * @see javax.naming.InitialContext 43 * @since 1.3 44 */ 45 46 public class InitialDirContext extends InitialContext implements DirContext { 47 48 /** 49 * Constructs an initial DirContext with the option of not 50 * initializing it. This may be used by a constructor in 51 * a subclass when the value of the environment parameter 52 * is not yet known at the time the {@code InitialDirContext} 53 * constructor is called. The subclass's constructor will 54 * call this constructor, compute the value of the environment, 55 * and then call {@code init()} before returning. 56 * 57 * @param lazy 58 * true means do not initialize the initial DirContext; false 59 * is equivalent to calling {@code new InitialDirContext()} 60 * @throws NamingException if a naming exception is encountered 61 * 62 * @see InitialContext#init(Hashtable) 63 * @since 1.3 64 */ 65 protected InitialDirContext(boolean lazy) throws NamingException { 66 super(lazy); 67 } 68 69 /** 70 * Constructs an initial DirContext. 71 * No environment properties are supplied. 72 * Equivalent to {@code new InitialDirContext(null)}. 73 * 74 * @throws NamingException if a naming exception is encountered 75 * 76 * @see #InitialDirContext(Hashtable) 77 */ 78 public InitialDirContext() throws NamingException { 79 super(); 80 } 81 82 /** 83 * Constructs an initial DirContext using the supplied environment. 84 * Environment properties are discussed in the 85 * {@code javax.naming.InitialContext} class description. 86 * 87 * <p> This constructor will not modify {@code environment} 88 * or save a reference to it, but may save a clone. 89 * Caller should not modify mutable keys and values in 90 * {@code environment} after it has been passed to the constructor. 91 * 92 * @param environment 93 * environment used to create the initial DirContext. 94 * Null indicates an empty environment. 95 * 96 * @throws NamingException if a naming exception is encountered 97 */ 98 public InitialDirContext(Hashtable<?,?> environment) 99 throws NamingException 100 { 101 super(environment); 102 } 103 104 private DirContext getURLOrDefaultInitDirCtx(String name) 105 throws NamingException { 106 Context answer = getURLOrDefaultInitCtx(name); 107 if (!(answer instanceof DirContext)) { 108 if (answer == null) { 109 throw new NoInitialContextException(); 110 } else { |