- Uses of Interface javax.naming.Context
- Uses of Context in javax.naming
- Uses of Context in javax.naming.directory
- Uses of Context in javax.naming.event
- Uses of Context in javax.naming.ldap
- Uses of Context in javax.naming.spi
- Uses of Context in javax.sql.rowset.spi
- Names
- Exceptions
- Concurrent Access
- Parameters
- Environment Properties
- Resource Files
- Provider Resource Files
- Application Resource Files
- Search Algorithm for Properties
- Field Summary
- Method Summary
Uses of Interface
javax.naming.Context
Provides the means for dynamically plugging in support for accessing naming and directory services through the javax.naming and related packages.
The standard classes and interfaces that a third party vendor has to use in its implementation of a synchronization provider.
Uses of Context in javax.naming
Retrieves the initial context by calling NamingManager.getInitialContext() and cache it in defaultInitCtx.
Uses of Context in javax.naming.directory
The directory service interface, containing methods for examining and updating attributes associated with objects, and for searching the directory.
Uses of Context in javax.naming.event
Contains methods for registering/deregistering listeners to be notified of events fired when objects named in a context changes.
Contains methods for registering listeners to be notified of events fired when objects named in a directory context changes.
Uses of Context in javax.naming.ldap
This interface represents a context in which you can perform operations with LDAPv3-style controls and perform LDAPv3-style extended operations.
Retrieves the context at which to continue the method using the context’s environment and no controls.
Retrieves the context at which to continue the method using request controls and environment properties.
Uses of Context in javax.naming.spi
DirectoryManager. getObjectInstance (Object refInfo, Name name, Context nameCtx, Hashtable environment, Attributes attrs)
DirStateFactory. getStateToBind (Object obj, Name name, Context nameCtx, Hashtable environment, Attributes inAttrs)
Uses of Context in javax.sql.rowset.spi
Sets the initial JNDI context from which SyncProvider implementations can be retrieved from a JNDI namespace
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2023, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.
Names
Each name passed as an argument to a Context method is relative to that context. The empty name is used to name the context itself. A name parameter may never be null. Most of the methods have overloaded versions with one taking a Name parameter and one taking a String . These overloaded versions are equivalent in that if the Name and String parameters are just different representations of the same name, then the overloaded versions of the same methods behave the same. In the method descriptions below, only one version is fully documented. The second version instead has a link to the first: the same documentation applies to both. For systems that support federation, String name arguments to Context methods are composite names. Name arguments that are instances of CompositeName are treated as composite names, while Name arguments that are not instances of CompositeName are treated as compound names (which might be instances of CompoundName or other implementations of compound names). This allows the results of NameParser.parse() to be used as arguments to the Context methods. Prior to JNDI 1.2, all name arguments were treated as composite names. Furthermore, for systems that support federation, all names returned in a NamingEnumeration from list() and listBindings() are composite names represented as strings. See CompositeName for the string syntax of names. For systems that do not support federation, the name arguments (in either Name or String forms) and the names returned in NamingEnumeration may be names in their own namespace rather than names in a composite namespace, at the discretion of the service provider.
Exceptions
All the methods in this interface can throw a NamingException or any of its subclasses. See NamingException and their subclasses for details on each exception.
Concurrent Access
A Context instance is not guaranteed to be synchronized against concurrent access by multiple threads. Threads that need to access a single Context instance concurrently should synchronize amongst themselves and provide the necessary locking. Multiple threads each manipulating a different Context instance need not synchronize. Note that the lookup method, when passed an empty name, will return a new Context instance representing the same naming context. For purposes of concurrency control, a Context operation that returns a NamingEnumeration is not considered to have completed while the enumeration is still in use, or while any referrals generated by that operation are still being followed.
Parameters
A Name parameter passed to any method of the Context interface or one of its subinterfaces will not be modified by the service provider. The service provider may keep a reference to it for the duration of the operation, including any enumeration of the method’s results and the processing of any referrals generated. The caller should not modify the object during this time. A Name returned by any such method is owned by the caller. The caller may subsequently modify it; the service provider may not.
Environment Properties
JNDI applications need a way to communicate various preferences and properties that define the environment in which naming and directory services are accessed. For example, a context might require specification of security credentials in order to access the service. Another context might require that server configuration information be supplied. These are referred to as the environment of a context. The Context interface provides methods for retrieving and updating this environment. The environment is inherited from the parent context as context methods proceed from one context to the next. Changes to the environment of one context do not directly affect those of other contexts. It is implementation-dependent when environment properties are used and/or verified for validity. For example, some of the security-related properties are used by service providers to «log in» to the directory. This login process might occur at the time the context is created, or the first time a method is invoked on the context. When, and whether this occurs at all, is implementation-dependent. When environment properties are added or removed from the context, verifying the validity of the changes is again implementation-dependent. For example, verification of some properties might occur at the time the change is made, or at the time the next operation is performed on the context, or not at all. Any object with a reference to a context may examine that context’s environment. Sensitive information such as clear-text passwords should not be stored there unless the implementation is known to protect it.
Resource Files
To simplify the task of setting up the environment required by a JNDI application, application components and service providers may be distributed along with resource files. A JNDI resource file is a file in the properties file format (see java.util.Properties ), containing a list of key/value pairs. The key is the name of the property (e.g. «java.naming.factory.object») and the value is a string in the format defined for that property. Here is an example of a JNDI resource file:
java.naming.factory.object=com.sun.jndi.ldap.AttrsToCorba:com.wiz.from.Person java.naming.factory.state=com.sun.jndi.ldap.CorbaToAttrs:com.wiz.from.Person java.naming.factory.control=com.sun.jndi.ldap.ResponseControlFactory
The JNDI class library reads the resource files and makes the property values freely available. Thus JNDI resource files should be considered to be «world readable», and sensitive information such as clear-text passwords should not be stored there. There are two kinds of JNDI resource files: provider and application.
Provider Resource Files
Each service provider has an optional resource that lists properties specific to that provider. The name of this resource is:
- java.naming.factory.object
- java.naming.factory.state
- java.naming.factory.control
- java.naming.factory.url.pkgs
Application Resource Files
When an application is deployed, it will generally have several codebase directories and JARs in its classpath. Similarly, when an applet is deployed, it will have a codebase and archives specifying where to find the applet’s classes. JNDI locates (using ClassLoader.getResources() ) all application resource files named jndi.properties in the classpath. In addition, if the file java.home/lib/jndi.properties exists and is readable, JNDI treats it as an additional application resource file. (java.home indicates the directory named by the java.home system property.) All of the properties contained in these files are placed into the environment of the initial context. This environment is then inherited by other contexts. For each property found in more than one application resource file, JNDI uses the first value found or, in a few cases where it makes sense to do so, it concatenates all of the values (details are given below). For example, if the «java.naming.factory.object» property is found in three jndi.properties resource files, the list of object factories is a concatenation of the property values from all three files. Using this scheme, each deployable component is responsible for listing the factories that it exports. JNDI automatically collects and uses all of these export lists when searching for factory classes.
Search Algorithm for Properties
- The environment of the context being operated on.
- The provider resource file (jndiprovider.properties) for the context being operated on.
Field Summary
Constant that holds the name of the environment property for specifying an applet for the initial context constructor to use when searching for other properties.
Constant that holds the name of the environment property for specifying the authoritativeness of the service requested.
Constant that holds the name of the environment property for specifying the batch size to use when returning data via the service’s protocol.
Constant that holds the name of the environment property for specifying the DNS host and domain names to use for the JNDI URL context (for example, «dns://somehost/wiz.com»).
Constant that holds the name of the environment property for specifying the initial context factory to use.
Constant that holds the name of the environment property for specifying the preferred language to use with the service.
Constant that holds the name of the environment property for specifying the list of object factories to use.
Constant that holds the name of the environment property for specifying configuration information for the service provider to use.
Constant that holds the name of the environment property for specifying how referrals encountered by the service provider are to be processed.
Constant that holds the name of the environment property for specifying the credentials of the principal for authenticating the caller to the service.
Constant that holds the name of the environment property for specifying the identity of the principal for authenticating the caller to the service.
Constant that holds the name of the environment property for specifying the security protocol to use.
Constant that holds the name of the environment property for specifying the list of state factories to use.
Constant that holds the name of the environment property for specifying the list of package prefixes to use when loading in URL context factories.