Module java.naming

Class InitialDirContext

java.lang.Object
javax.naming.InitialContext
javax.naming.directory.InitialDirContext
All Implemented Interfaces:
Context, DirContext
Direct Known Subclasses:
InitialLdapContext

public class InitialDirContext
extends InitialContext
implements DirContext
This class is the starting context for performing directory operations. The documentation in the class description of InitialContext (including those for synchronization) apply here.
Since:
1.3
See Also:
InitialContext
  • Constructor Details

    • InitialDirContext

      protected InitialDirContext​(boolean lazy) throws NamingException
      Constructs an initial DirContext 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 InitialDirContext constructor is called. The subclass's constructor will call this constructor, compute the value of the environment, and then call init() before returning.
      Parameters:
      lazy - true means do not initialize the initial DirContext; false is equivalent to calling new InitialDirContext()
      Throws:
      NamingException - if a naming exception is encountered
      Since:
      1.3
      See Also:
      InitialContext.init(Hashtable)
    • InitialDirContext

      public InitialDirContext() throws NamingException
      Constructs an initial DirContext. No environment properties are supplied. Equivalent to new InitialDirContext(null).
      Throws:
      NamingException - if a naming exception is encountered
      See Also:
      InitialDirContext(Hashtable)
    • InitialDirContext

      public InitialDirContext​(Hashtable<?,​?> environment) throws NamingException
      Constructs an initial DirContext using the supplied environment. Environment properties are discussed in the javax.naming.InitialContext class description.

      If the java.naming.provider.url property of the supplied environment consists of a URL (or a list of URLs) using the ldap protocol the resulting LdapContext will use an LDAP server resolved by the configured LdapDnsProviders:

      1. If this is the first InitialDirContext created with a java.naming.provider.url using the ldap protocol then the ServiceLoader mechanism is used to locate LdapDnsProvider implementations using the system class loader. The order that providers are located is implementation specific and an implementation is free to cache the located providers.
      2. The lookupEndpoints method of each provider, if instantiated, is invoked once with a combination of each of the URLs in the the java.naming.provider.url property and the environment until a provider returns non-empty or all providers have been exhausted. If none of the LdapDnsProviders return a non-empty result then the implementation will make a best-effort attempt to determine an endpoint. A ServiceConfigurationError, Error or RuntimeException thrown when loading or calling an LdapDnsProvider, if encountered, will be propagated to the calling thread.

      This constructor will not modify environment or save a reference to it, but may save a clone. Caller should not modify mutable keys and values in environment after it has been passed to the constructor.

      Parameters:
      environment - environment used to create the initial DirContext. Null indicates an empty environment.
      Throws:
      NamingException - if a naming exception is encountered