Path: blob/master/src/java.naming/share/classes/javax/naming/Context.java
41152 views
/*1* Copyright (c) 1999, 2021, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.naming;2627import java.util.Hashtable;2829/**30* This interface represents a naming context, which31* consists of a set of name-to-object bindings.32* It contains methods for examining and updating these bindings.33*34* <h2>Names</h2>35* Each name passed as an argument to a {@code Context} method is relative36* to that context. The empty name is used to name the context itself.37* A name parameter may never be null.38* <p>39* Most of the methods have overloaded versions with one taking a40* <code>Name</code> parameter and one taking a <code>String</code>.41* These overloaded versions are equivalent in that if42* the <code>Name</code> and <code>String</code> parameters are just43* different representations of the same name, then the overloaded44* versions of the same methods behave the same.45* In the method descriptions below, only one version is fully documented.46* The second version instead has a link to the first: the same47* documentation applies to both.48* <p>49* For systems that support federation, {@code String} name arguments to50* {@code Context} methods are composite names. Name arguments that are51* instances of {@code CompositeName} are treated as composite names,52* while {@code Name} arguments that are not instances of53* {@code CompositeName} are treated as compound names (which might be54* instances of {@code CompoundName} or other implementations of compound55* names). This allows the results of {@code NameParser.parse()} to be used as56* arguments to the {@code Context} methods.57* Prior to JNDI 1.2, all name arguments were treated as composite names.58*<p>59* Furthermore, for systems that support federation, all names returned60* in a {@code NamingEnumeration}61* from {@code list()} and {@code listBindings()} are composite names62* represented as strings.63* See {@code CompositeName} for the string syntax of names.64*<p>65* For systems that do not support federation, the name arguments (in66* either {@code Name} or {@code String} forms) and the names returned in67* {@code NamingEnumeration} may be names in their own namespace rather than68* names in a composite namespace, at the discretion of the service69* provider.70*71*<h2>Exceptions</h2>72* All the methods in this interface can throw a {@code NamingException} or73* any of its subclasses. See {@code NamingException} and their subclasses74* for details on each exception.75*76*<h2>Concurrent Access</h2>77* A Context instance is not guaranteed to be synchronized against78* concurrent access by multiple threads. Threads that need to access79* a single Context instance concurrently should synchronize amongst80* themselves and provide the necessary locking. Multiple threads81* each manipulating a different Context instance need not82* synchronize. Note that the {@link #lookup(Name) lookup}83* method, when passed an empty name, will return a new Context instance84* representing the same naming context.85*<p>86* For purposes of concurrency control,87* a Context operation that returns a {@code NamingEnumeration} is88* not considered to have completed while the enumeration is still in89* use, or while any referrals generated by that operation are still90* being followed.91*92*93*<h2>Parameters</h2>94* A {@code Name} parameter passed to any method of the95* {@code Context} interface or one of its subinterfaces96* will not be modified by the service provider.97* The service provider may keep a reference to it98* for the duration of the operation, including any enumeration of the99* method's results and the processing of any referrals generated.100* The caller should not modify the object during this time.101* A {@code Name} returned by any such method is owned by the caller.102* The caller may subsequently modify it; the service provider may not.103*104*105*<h2>Environment Properties</h2>106*<p>107* JNDI applications need a way to communicate various preferences108* and properties that define the environment in which naming and109* directory services are accessed. For example, a context might110* require specification of security credentials in order to access111* the service. Another context might require that server configuration112* information be supplied. These are referred to as the <em>environment</em>113* of a context. The {@code Context} interface provides methods for114* retrieving and updating this environment.115*<p>116* The environment is inherited from the parent context as117* context methods proceed from one context to the next. Changes to118* the environment of one context do not directly affect those119* of other contexts.120*<p>121* It is implementation-dependent when environment properties are used122* and/or verified for validity. For example, some of the123* security-related properties are used by service providers to "log in"124* to the directory. This login process might occur at the time the125* context is created, or the first time a method is invoked on the126* context. When, and whether this occurs at all, is127* implementation-dependent. When environment properties are added or128* removed from the context, verifying the validity of the changes is again129* implementation-dependent. For example, verification of some properties130* might occur at the time the change is made, or at the time the next131* operation is performed on the context, or not at all.132*<p>133* Any object with a reference to a context may examine that context's134* environment. Sensitive information such as clear-text135* passwords should not be stored there unless the implementation is136* known to protect it.137*138*<p>139*<a id=RESOURCEFILES></a>140*<h2>Resource Files</h2>141*<p>142* To simplify the task of setting up the environment143* required by a JNDI application,144* application components and service providers may be distributed145* along with <em>resource files.</em>146* A JNDI resource file is a file in the properties file format (see147* {@link java.util.Properties#load java.util.Properties}),148* containing a list of key/value pairs.149* The key is the name of the property (e.g. "java.naming.factory.object")150* and the value is a string in the format defined151* for that property. Here is an example of a JNDI resource file:152*153* <blockquote>{@code154* java.naming.factory.object=com.sun.jndi.ldap.AttrsToCorba:com.wiz.from.Person155* java.naming.factory.state=com.sun.jndi.ldap.CorbaToAttrs:com.wiz.from.Person156* java.naming.factory.control=com.sun.jndi.ldap.ResponseControlFactory157* }</blockquote>158*159* The JNDI class library reads the resource files and makes the property160* values freely available. Thus JNDI resource files should be considered161* to be "world readable", and sensitive information such as clear-text162* passwords should not be stored there.163*<p>164* There are two kinds of JNDI resource files:165* <em>provider</em> and <em>application</em>.166*167* <h3>Provider Resource Files</h3>168*169* Each service provider has an optional resource that lists properties170* specific to that provider. The name of this resource is:171* <blockquote>172* [<em>prefix</em>/]{@code jndiprovider.properties}173* </blockquote>174* where <em>prefix</em> is175* the package name of the provider's context implementation(s),176* with each period (".") converted to a slash ("/").177*178* For example, suppose a service provider defines a context179* implementation with class name {@code com.sun.jndi.ldap.LdapCtx}.180* The provider resource for this provider is named181* {@code com/sun/jndi/ldap/jndiprovider.properties}. If the class is182* not in a package, the resource's name is simply183* {@code jndiprovider.properties}.184*185* <p>186* <a id=LISTPROPS></a>187* Certain methods in the JNDI class library make use of the standard188* JNDI properties that specify lists of JNDI factories:189* <ul>190* <li>java.naming.factory.object191* <li>java.naming.factory.state192* <li>java.naming.factory.control193* <li>java.naming.factory.url.pkgs194* </ul>195* The JNDI library will consult the provider resource file196* when determining the values of these properties.197* Properties other than these may be set in the provider198* resource file at the discretion of the service provider.199* The service provider's documentation should clearly state which200* properties are allowed; other properties in the file will be ignored.201*202* <h3>Application Resource Files</h3>203*204* When an application is deployed, it will generally have several205* codebase directories and JARs in its classpath. JNDI locates (using206* {@link ClassLoader#getResources ClassLoader.getResources()})207* all <em>application resource files</em> named {@code jndi.properties}208* in the classpath.209* In addition, if the Java installation directory contains a built-in210* properties file, typically {@code conf/jndi.properties},211* JNDI treats it as an additional application resource file.212* All of the properties contained in these files are placed213* into the environment of the initial context. This environment214* is then inherited by other contexts.215*216* <p>217* For each property found in more than one application resource file,218* JNDI uses the first value found or, in a few cases where it makes219* sense to do so, it concatenates all of the values (details are given220* below).221* For example, if the "java.naming.factory.object" property is found in222* three {@code jndi.properties} resource files, the223* list of object factories is a concatenation of the property224* values from all three files.225* Using this scheme, each deployable component is responsible for226* listing the factories that it exports. JNDI automatically227* collects and uses all of these export lists when searching for factory228* classes.229*230* <h3>Search Algorithm for Properties</h3>231*232* When JNDI constructs an initial context, the context's environment233* is initialized with properties defined in the environment parameter234* passed to the constructor, the system properties,235* and the application resource files. See236* <a href=InitialContext.html#ENVIRONMENT>{@code InitialContext}</a>237* for details.238* This initial environment is then inherited by other context instances.239*240* <p>241* When the JNDI class library needs to determine242* the value of a property, it does so by merging243* the values from the following two sources, in order:244* <ol>245* <li>The environment of the context being operated on.246* <li>The provider resource file ({@code jndiprovider.properties})247* for the context being operated on.248* </ol>249* For each property found in both of these two sources,250* JNDI determines the property's value as follows. If the property is251* one of the standard JNDI properties that specify a list of JNDI252* factories (listed <a href=#LISTPROPS>above</a>), the values are253* concatenated into a single colon-separated list. For other254* properties, only the first value found is used.255*256* <p>257* When a service provider needs to determine the value of a property,258* it will generally take that value directly from the environment.259* A service provider may define provider-specific properties260* to be placed in its own provider resource file. In that261* case it should merge values as described in the previous paragraph.262*263* <p>264* In this way, each service provider developer can specify a list of265* factories to use with that service provider. These can be modified by266* the application resources specified by the deployer of the application,267* which in turn can be modified by the user.268*269* @author Rosanna Lee270* @author Scott Seligman271* @author R. Vasudevan272*273* @since 1.3274*/275276public interface Context {277278/**279* Retrieves the named object.280* If {@code name} is empty, returns a new instance of this context281* (which represents the same naming context as this context, but its282* environment may be modified independently and it may be accessed283* concurrently).284*285* @param name286* the name of the object to look up287* @return the object bound to {@code name}288* @throws NamingException if a naming exception is encountered289*290* @see #lookup(String)291* @see #lookupLink(Name)292*/293public Object lookup(Name name) throws NamingException;294295/**296* Retrieves the named object.297* See {@link #lookup(Name)} for details.298* @param name299* the name of the object to look up300* @return the object bound to {@code name}301* @throws NamingException if a naming exception is encountered302*/303public Object lookup(String name) throws NamingException;304305/**306* Binds a name to an object.307* All intermediate contexts and the target context (that named by all308* but terminal atomic component of the name) must already exist.309*310* @param name311* the name to bind; may not be empty312* @param obj313* the object to bind; possibly null314* @throws NameAlreadyBoundException if name is already bound315* @throws javax.naming.directory.InvalidAttributesException316* if object did not supply all mandatory attributes317* @throws NamingException if a naming exception is encountered318*319* @see #bind(String, Object)320* @see #rebind(Name, Object)321* @see javax.naming.directory.DirContext#bind(Name, Object,322* javax.naming.directory.Attributes)323*/324public void bind(Name name, Object obj) throws NamingException;325326/**327* Binds a name to an object.328* See {@link #bind(Name, Object)} for details.329*330* @param name331* the name to bind; may not be empty332* @param obj333* the object to bind; possibly null334* @throws NameAlreadyBoundException if name is already bound335* @throws javax.naming.directory.InvalidAttributesException336* if object did not supply all mandatory attributes337* @throws NamingException if a naming exception is encountered338*/339public void bind(String name, Object obj) throws NamingException;340341/**342* Binds a name to an object, overwriting any existing binding.343* All intermediate contexts and the target context (that named by all344* but terminal atomic component of the name) must already exist.345*346* <p> If the object is a {@code DirContext}, any existing attributes347* associated with the name are replaced with those of the object.348* Otherwise, any existing attributes associated with the name remain349* unchanged.350*351* @param name352* the name to bind; may not be empty353* @param obj354* the object to bind; possibly null355* @throws javax.naming.directory.InvalidAttributesException356* if object did not supply all mandatory attributes357* @throws NamingException if a naming exception is encountered358*359* @see #rebind(String, Object)360* @see #bind(Name, Object)361* @see javax.naming.directory.DirContext#rebind(Name, Object,362* javax.naming.directory.Attributes)363* @see javax.naming.directory.DirContext364*/365public void rebind(Name name, Object obj) throws NamingException;366367/**368* Binds a name to an object, overwriting any existing binding.369* See {@link #rebind(Name, Object)} for details.370*371* @param name372* the name to bind; may not be empty373* @param obj374* the object to bind; possibly null375* @throws javax.naming.directory.InvalidAttributesException376* if object did not supply all mandatory attributes377* @throws NamingException if a naming exception is encountered378*/379public void rebind(String name, Object obj) throws NamingException;380381/**382* Unbinds the named object.383* Removes the terminal atomic name in <code>name</code>384* from the target context--that named by all but the terminal385* atomic part of <code>name</code>.386*387* <p> This method is idempotent.388* It succeeds even if the terminal atomic name389* is not bound in the target context, but throws390* {@code NameNotFoundException}391* if any of the intermediate contexts do not exist.392*393* <p> Any attributes associated with the name are removed.394* Intermediate contexts are not changed.395*396* @param name397* the name to unbind; may not be empty398* @throws NameNotFoundException if an intermediate context does not exist399* @throws NamingException if a naming exception is encountered400* @see #unbind(String)401*/402public void unbind(Name name) throws NamingException;403404/**405* Unbinds the named object.406* See {@link #unbind(Name)} for details.407*408* @param name409* the name to unbind; may not be empty410* @throws NameNotFoundException if an intermediate context does not exist411* @throws NamingException if a naming exception is encountered412*/413public void unbind(String name) throws NamingException;414415/**416* Binds a new name to the object bound to an old name, and unbinds417* the old name. Both names are relative to this context.418* Any attributes associated with the old name become associated419* with the new name.420* Intermediate contexts of the old name are not changed.421*422* @param oldName423* the name of the existing binding; may not be empty424* @param newName425* the name of the new binding; may not be empty426* @throws NameAlreadyBoundException if {@code newName} is already bound427* @throws NamingException if a naming exception is encountered428*429* @see #rename(String, String)430* @see #bind(Name, Object)431* @see #rebind(Name, Object)432*/433public void rename(Name oldName, Name newName) throws NamingException;434435/**436* Binds a new name to the object bound to an old name, and unbinds437* the old name.438* See {@link #rename(Name, Name)} for details.439*440* @param oldName441* the name of the existing binding; may not be empty442* @param newName443* the name of the new binding; may not be empty444* @throws NameAlreadyBoundException if {@code newName} is already bound445* @throws NamingException if a naming exception is encountered446*/447public void rename(String oldName, String newName) throws NamingException;448449/**450* Enumerates the names bound in the named context, along with the451* class names of objects bound to them.452* The contents of any subcontexts are not included.453*454* <p> If a binding is added to or removed from this context,455* its effect on an enumeration previously returned is undefined.456*457* @param name458* the name of the context to list459* @return an enumeration of the names and class names of the460* bindings in this context. Each element of the461* enumeration is of type {@code NameClassPair}.462* @throws NamingException if a naming exception is encountered463*464* @see #list(String)465* @see #listBindings(Name)466* @see NameClassPair467*/468public NamingEnumeration<NameClassPair> list(Name name)469throws NamingException;470471/**472* Enumerates the names bound in the named context, along with the473* class names of objects bound to them.474* See {@link #list(Name)} for details.475*476* @param name477* the name of the context to list478* @return an enumeration of the names and class names of the479* bindings in this context. Each element of the480* enumeration is of type {@code NameClassPair}.481* @throws NamingException if a naming exception is encountered482*/483public NamingEnumeration<NameClassPair> list(String name)484throws NamingException;485486/**487* Enumerates the names bound in the named context, along with the488* objects bound to them.489* The contents of any subcontexts are not included.490*491* <p> If a binding is added to or removed from this context,492* its effect on an enumeration previously returned is undefined.493*494* @param name495* the name of the context to list496* @return an enumeration of the bindings in this context.497* Each element of the enumeration is of type498* {@code Binding}.499* @throws NamingException if a naming exception is encountered500*501* @see #listBindings(String)502* @see #list(Name)503* @see Binding504*/505public NamingEnumeration<Binding> listBindings(Name name)506throws NamingException;507508/**509* Enumerates the names bound in the named context, along with the510* objects bound to them.511* See {@link #listBindings(Name)} for details.512*513* @param name514* the name of the context to list515* @return an enumeration of the bindings in this context.516* Each element of the enumeration is of type517* {@code Binding}.518* @throws NamingException if a naming exception is encountered519*/520public NamingEnumeration<Binding> listBindings(String name)521throws NamingException;522523/**524* Destroys the named context and removes it from the namespace.525* Any attributes associated with the name are also removed.526* Intermediate contexts are not destroyed.527*528* <p> This method is idempotent.529* It succeeds even if the terminal atomic name530* is not bound in the target context, but throws531* {@code NameNotFoundException}532* if any of the intermediate contexts do not exist.533*534* <p> In a federated naming system, a context from one naming system535* may be bound to a name in another. One can subsequently536* look up and perform operations on the foreign context using a537* composite name. However, an attempt destroy the context using538* this composite name will fail with539* {@code NotContextException}, because the foreign context is not540* a "subcontext" of the context in which it is bound.541* Instead, use {@code unbind()} to remove the542* binding of the foreign context. Destroying the foreign context543* requires that the {@code destroySubcontext()} be performed544* on a context from the foreign context's "native" naming system.545*546* @param name547* the name of the context to be destroyed; may not be empty548* @throws NameNotFoundException if an intermediate context does not exist549* @throws NotContextException if the name is bound but does not name a550* context, or does not name a context of the appropriate type551* @throws ContextNotEmptyException if the named context is not empty552* @throws NamingException if a naming exception is encountered553*554* @see #destroySubcontext(String)555*/556public void destroySubcontext(Name name) throws NamingException;557558/**559* Destroys the named context and removes it from the namespace.560* See {@link #destroySubcontext(Name)} for details.561*562* @param name563* the name of the context to be destroyed; may not be empty564* @throws NameNotFoundException if an intermediate context does not exist565* @throws NotContextException if the name is bound but does not name a566* context, or does not name a context of the appropriate type567* @throws ContextNotEmptyException if the named context is not empty568* @throws NamingException if a naming exception is encountered569*/570public void destroySubcontext(String name) throws NamingException;571572/**573* Creates and binds a new context.574* Creates a new context with the given name and binds it in575* the target context (that named by all but terminal atomic576* component of the name). All intermediate contexts and the577* target context must already exist.578*579* @param name580* the name of the context to create; may not be empty581* @return the newly created context582*583* @throws NameAlreadyBoundException if name is already bound584* @throws javax.naming.directory.InvalidAttributesException585* if creation of the subcontext requires specification of586* mandatory attributes587* @throws NamingException if a naming exception is encountered588*589* @see #createSubcontext(String)590* @see javax.naming.directory.DirContext#createSubcontext591*/592public Context createSubcontext(Name name) throws NamingException;593594/**595* Creates and binds a new context.596* See {@link #createSubcontext(Name)} for details.597*598* @param name599* the name of the context to create; may not be empty600* @return the newly created context601*602* @throws NameAlreadyBoundException if name is already bound603* @throws javax.naming.directory.InvalidAttributesException604* if creation of the subcontext requires specification of605* mandatory attributes606* @throws NamingException if a naming exception is encountered607*/608public Context createSubcontext(String name) throws NamingException;609610/**611* Retrieves the named object, following links except612* for the terminal atomic component of the name.613* If the object bound to {@code name} is not a link,614* returns the object itself.615*616* @param name617* the name of the object to look up618* @return the object bound to {@code name}, not following the619* terminal link (if any).620* @throws NamingException if a naming exception is encountered621*622* @see #lookupLink(String)623*/624public Object lookupLink(Name name) throws NamingException;625626/**627* Retrieves the named object, following links except628* for the terminal atomic component of the name.629* See {@link #lookupLink(Name)} for details.630*631* @param name632* the name of the object to look up633* @return the object bound to {@code name}, not following the634* terminal link (if any)635* @throws NamingException if a naming exception is encountered636*/637public Object lookupLink(String name) throws NamingException;638639/**640* Retrieves the parser associated with the named context.641* In a federation of namespaces, different naming systems will642* parse names differently. This method allows an application643* to get a parser for parsing names into their atomic components644* using the naming convention of a particular naming system.645* Within any single naming system, {@code NameParser} objects646* returned by this method must be equal (using the {@code equals()}647* test).648*649* @param name650* the name of the context from which to get the parser651* @return a name parser that can parse compound names into their atomic652* components653* @throws NamingException if a naming exception is encountered654*655* @see #getNameParser(String)656* @see CompoundName657*/658public NameParser getNameParser(Name name) throws NamingException;659660/**661* Retrieves the parser associated with the named context.662* See {@link #getNameParser(Name)} for details.663*664* @param name665* the name of the context from which to get the parser666* @return a name parser that can parse compound names into their atomic667* components668* @throws NamingException if a naming exception is encountered669*/670public NameParser getNameParser(String name) throws NamingException;671672/**673* Composes the name of this context with a name relative to674* this context.675* Given a name (<code>name</code>) relative to this context, and676* the name (<code>prefix</code>) of this context relative to one677* of its ancestors, this method returns the composition of the678* two names using the syntax appropriate for the naming679* system(s) involved. That is, if <code>name</code> names an680* object relative to this context, the result is the name of the681* same object, but relative to the ancestor context. None of the682* names may be null.683* <p>684* For example, if this context is named "wiz.com" relative685* to the initial context, then686* <pre>687* composeName("east", "wiz.com") </pre>688* might return <code>"east.wiz.com"</code>.689* If instead this context is named "org/research", then690* <pre>691* composeName("user/jane", "org/research") </pre>692* might return <code>"org/research/user/jane"</code> while693* <pre>694* composeName("user/jane", "research") </pre>695* returns <code>"research/user/jane"</code>.696*697* @param name698* a name relative to this context699* @param prefix700* the name of this context relative to one of its ancestors701* @return the composition of <code>prefix</code> and <code>name</code>702* @throws NamingException if a naming exception is encountered703*704* @see #composeName(String, String)705*/706public Name composeName(Name name, Name prefix)707throws NamingException;708709/**710* Composes the name of this context with a name relative to711* this context.712* See {@link #composeName(Name, Name)} for details.713*714* @param name715* a name relative to this context716* @param prefix717* the name of this context relative to one of its ancestors718* @return the composition of <code>prefix</code> and <code>name</code>719* @throws NamingException if a naming exception is encountered720*/721public String composeName(String name, String prefix)722throws NamingException;723724/**725* Adds a new environment property to the environment of this726* context. If the property already exists, its value is overwritten.727* See class description for more details on environment properties.728*729* @param propName730* the name of the environment property to add; may not be null731* @param propVal732* the value of the property to add; may not be null733* @return the previous value of the property, or null if the property was734* not in the environment before735* @throws NamingException if a naming exception is encountered736*737* @see #getEnvironment()738* @see #removeFromEnvironment(String)739*/740public Object addToEnvironment(String propName, Object propVal)741throws NamingException;742743/**744* Removes an environment property from the environment of this745* context. See class description for more details on environment746* properties.747*748* @param propName749* the name of the environment property to remove; may not be null750* @return the previous value of the property, or null if the property was751* not in the environment752* @throws NamingException if a naming exception is encountered753*754* @see #getEnvironment()755* @see #addToEnvironment(String, Object)756*/757public Object removeFromEnvironment(String propName)758throws NamingException;759760/**761* Retrieves the environment in effect for this context.762* See class description for more details on environment properties.763*764* <p> The caller should not make any changes to the object returned:765* their effect on the context is undefined.766* The environment of this context may be changed using767* {@code addToEnvironment()} and {@code removeFromEnvironment()}.768*769* @return the environment of this context; never null770* @throws NamingException if a naming exception is encountered771*772* @see #addToEnvironment(String, Object)773* @see #removeFromEnvironment(String)774*/775public Hashtable<?,?> getEnvironment() throws NamingException;776777/**778* Closes this context.779* This method releases this context's resources immediately, instead of780* waiting for them to be released automatically by the garbage collector.781*782* <p> This method is idempotent: invoking it on a context that has783* already been closed has no effect. Invoking any other method784* on a closed context is not allowed, and results in undefined behaviour.785*786* @throws NamingException if a naming exception is encountered787*/788public void close() throws NamingException;789790/**791* Retrieves the full name of this context within its own namespace.792*793* <p> Many naming services have a notion of a "full name" for objects794* in their respective namespaces. For example, an LDAP entry has795* a distinguished name, and a DNS record has a fully qualified name.796* This method allows the client application to retrieve this name.797* The string returned by this method is not a JNDI composite name798* and should not be passed directly to context methods.799* In naming systems for which the notion of full name does not800* make sense, {@code OperationNotSupportedException} is thrown.801*802* @return this context's name in its own namespace; never null803* @throws OperationNotSupportedException if the naming system does804* not have the notion of a full name805* @throws NamingException if a naming exception is encountered806*807* @since 1.3808*/809public String getNameInNamespace() throws NamingException;810811// public static final: JLS says recommended style is to omit these modifiers812// because they are the default813814/**815* Constant that holds the name of the environment property816* for specifying the initial context factory to use. The value817* of the property should be the fully qualified class name818* of the factory class that will create an initial context.819* This property may be specified in the environment parameter820* passed to the initial context constructor,821* a system property, or an application resource file.822* If it is not specified in any of these sources,823* {@code NoInitialContextException} is thrown when an initial824* context is required to complete an operation.825*826* <p> The value of this constant is "java.naming.factory.initial".827*828* @see InitialContext829* @see javax.naming.directory.InitialDirContext830* @see javax.naming.spi.NamingManager#getInitialContext831* @see javax.naming.spi.InitialContextFactory832* @see NoInitialContextException833* @see #addToEnvironment(String, Object)834* @see #removeFromEnvironment(String)835*/836String INITIAL_CONTEXT_FACTORY = "java.naming.factory.initial";837838/**839* Constant that holds the name of the environment property840* for specifying the list of object factories to use. The value841* of the property should be a colon-separated list of the fully842* qualified class names of factory classes that will create an object843* given information about the object.844* This property may be specified in the environment, a system property,845* or one or more resource files.846*847* <p> The value of this constant is "java.naming.factory.object".848*849* @see javax.naming.spi.NamingManager#getObjectInstance850* @see javax.naming.spi.ObjectFactory851* @see #addToEnvironment(String, Object)852* @see #removeFromEnvironment(String)853*/854String OBJECT_FACTORIES = "java.naming.factory.object";855856/**857* Constant that holds the name of the environment property858* for specifying the list of state factories to use. The value859* of the property should be a colon-separated list of the fully860* qualified class names of state factory classes that will be used861* to get an object's state given the object itself.862* This property may be specified in the environment, a system property,863* or one or more resource files.864*865* <p> The value of this constant is "java.naming.factory.state".866*867* @see javax.naming.spi.NamingManager#getStateToBind868* @see javax.naming.spi.StateFactory869* @see #addToEnvironment(String, Object)870* @see #removeFromEnvironment(String)871* @since 1.3872*/873String STATE_FACTORIES = "java.naming.factory.state";874875/**876* Constant that holds the name of the environment property877* for specifying the list of package prefixes to use when878* loading in URL context factories. The value879* of the property should be a colon-separated list of package880* prefixes for the class name of the factory class that will create881* a URL context factory.882* This property may be specified in the environment, a system property,883* or one or more resource files.884* The prefix {@code com.sun.jndi.url} is always appended to885* the possibly empty list of package prefixes.886*887* <p> The value of this constant is "java.naming.factory.url.pkgs".888*889* @see javax.naming.spi.NamingManager#getObjectInstance890* @see javax.naming.spi.NamingManager#getURLContext891* @see javax.naming.spi.ObjectFactory892* @see #addToEnvironment(String, Object)893* @see #removeFromEnvironment(String)894*/895String URL_PKG_PREFIXES = "java.naming.factory.url.pkgs";896897/**898* Constant that holds the name of the environment property899* for specifying configuration information for the service provider900* to use. The value of the property should contain a URL string901* (e.g. "ldap://somehost:389").902* This property may be specified in the environment, a system property,903* or a resource file.904* If it is not specified in any of these sources,905* the default configuration is determined by the service provider.906*907* <p> The value of this constant is "java.naming.provider.url".908*909* @see #addToEnvironment(String, Object)910* @see #removeFromEnvironment(String)911*/912String PROVIDER_URL = "java.naming.provider.url";913914/**915* Constant that holds the name of the environment property916* for specifying the DNS host and domain names to use for the917* JNDI URL context (for example, "dns://somehost/wiz.com").918* This property may be specified in the environment, a system property,919* or a resource file.920* If it is not specified in any of these sources921* and the program attempts to use a JNDI URL containing a DNS name,922* a {@code ConfigurationException} will be thrown.923*924* <p> The value of this constant is "java.naming.dns.url".925*926* @see #addToEnvironment(String, Object)927* @see #removeFromEnvironment(String)928*/929String DNS_URL = "java.naming.dns.url";930931/**932* Constant that holds the name of the environment property for933* specifying the authoritativeness of the service requested.934* If the value of the property is the string "true", it means935* that the access is to the most authoritative source (i.e. bypass936* any cache or replicas). If the value is anything else,937* the source need not be (but may be) authoritative.938* If unspecified, the value defaults to "false".939*940* <p> The value of this constant is "java.naming.authoritative".941*942* @see #addToEnvironment(String, Object)943* @see #removeFromEnvironment(String)944*/945String AUTHORITATIVE = "java.naming.authoritative";946947/**948* Constant that holds the name of the environment property for949* specifying the batch size to use when returning data via the950* service's protocol. This is a hint to the provider to return951* the results of operations in batches of the specified size, so952* the provider can optimize its performance and usage of resources.953* The value of the property is the string representation of an954* integer.955* If unspecified, the batch size is determined by the service956* provider.957*958* <p> The value of this constant is "java.naming.batchsize".959*960* @see #addToEnvironment(String, Object)961* @see #removeFromEnvironment(String)962*/963String BATCHSIZE = "java.naming.batchsize";964965/**966* Constant that holds the name of the environment property for967* specifying how referrals encountered by the service provider968* are to be processed. The value of the property is one of the969* following strings:970* <dl>971* <dt>"follow"972* <dd>follow referrals automatically973* <dt>"ignore"974* <dd>ignore referrals975* <dt>"throw"976* <dd>throw {@code ReferralException} when a referral is encountered.977* </dl>978* If this property is not specified, the default is979* determined by the provider.980*981* <p> The value of this constant is "java.naming.referral".982*983* @see #addToEnvironment(String, Object)984* @see #removeFromEnvironment(String)985*/986String REFERRAL = "java.naming.referral";987988/**989* Constant that holds the name of the environment property for990* specifying the security protocol to use.991* Its value is a string determined by the service provider992* (e.g. "ssl").993* If this property is unspecified,994* the behaviour is determined by the service provider.995*996* <p> The value of this constant is "java.naming.security.protocol".997*998* @see #addToEnvironment(String, Object)999* @see #removeFromEnvironment(String)1000*/1001String SECURITY_PROTOCOL = "java.naming.security.protocol";10021003/**1004* Constant that holds the name of the environment property for1005* specifying the security level to use.1006* Its value is one of the following strings:1007* "none", "simple", "strong".1008* If this property is unspecified,1009* the behaviour is determined by the service provider.1010*1011* <p> The value of this constant is "java.naming.security.authentication".1012*1013* @see #addToEnvironment(String, Object)1014* @see #removeFromEnvironment(String)1015*/1016String SECURITY_AUTHENTICATION = "java.naming.security.authentication";10171018/**1019* Constant that holds the name of the environment property for1020* specifying the identity of the principal for authenticating1021* the caller to the service. The format of the principal1022* depends on the authentication scheme.1023* If this property is unspecified,1024* the behaviour is determined by the service provider.1025*1026* <p> The value of this constant is "java.naming.security.principal".1027*1028* @see #addToEnvironment(String, Object)1029* @see #removeFromEnvironment(String)1030*/1031String SECURITY_PRINCIPAL = "java.naming.security.principal";10321033/**1034* Constant that holds the name of the environment property for1035* specifying the credentials of the principal for authenticating1036* the caller to the service. The value of the property depends1037* on the authentication scheme. For example, it could be a hashed1038* password, clear-text password, key, certificate, and so on.1039* If this property is unspecified,1040* the behaviour is determined by the service provider.1041*1042* <p> The value of this constant is "java.naming.security.credentials".1043*1044* @see #addToEnvironment(String, Object)1045* @see #removeFromEnvironment(String)1046*/10471048String SECURITY_CREDENTIALS = "java.naming.security.credentials";1049/**1050* Constant that holds the name of the environment property for1051* specifying the preferred language to use with the service.1052* The value of the property is a colon-separated list of language1053* tags as defined in RFC 1766.1054* If this property is unspecified,1055* the language preference is determined by the service provider.1056*1057* <p> The value of this constant is "java.naming.language".1058*1059* @see #addToEnvironment(String, Object)1060* @see #removeFromEnvironment(String)1061*/1062String LANGUAGE = "java.naming.language";10631064/**1065* @deprecated An environment property with this name is ignored1066* while constructing an initial context.1067* This constant was originally used as a property name to specify an1068* {@code Applet} to retrieve parameters from, when creating an initial1069* context. Currently any applet properties that need to be passed to an1070* initial context should be copied into the environment hashtable:1071* <pre>{@code1072* Hashtable env = new Hashtable();1073* env.put(Context.INITIAL_CONTEXT_FACTORY,1074* ((Applet) this).getParameter(Context.INITIAL_CONTEXT_FACTORY));1075* env.put(Context.PROVIDER_URL,1076* ((Applet) this).getParameter(Context.PROVIDER_URL));1077* // ... other properties ...1078*1079* Context ctx = new InitialContext(env);1080* }</pre>1081*1082* @since 1.31083*/1084@Deprecated(since = "9", forRemoval = true)1085String APPLET = "java.naming.applet";1086};108710881089