Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/naming/Context.java
38829 views
/*1* Copyright (c) 1999, 2013, 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* <h1>Names</h1>35* Each name passed as an argument to a <tt>Context</tt> 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, <tt>String</tt> name arguments to50* <tt>Context</tt> methods are composite names. Name arguments that are51* instances of <tt>CompositeName</tt> are treated as composite names,52* while <tt>Name</tt> arguments that are not instances of53* <tt>CompositeName</tt> are treated as compound names (which might be54* instances of <tt>CompoundName</tt> or other implementations of compound55* names). This allows the results of <tt>NameParser.parse()</tt> to be used as56* arguments to the <tt>Context</tt> 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 <tt>NamingEnumeration</tt>61* from <tt>list()</tt> and <tt>listBindings()</tt> are composite names62* represented as strings.63* See <tt>CompositeName</tt> for the string syntax of names.64*<p>65* For systems that do not support federation, the name arguments (in66* either <tt>Name</tt> or <tt>String</tt> forms) and the names returned in67* <tt>NamingEnumeration</tt> may be names in their own namespace rather than68* names in a composite namespace, at the discretion of the service69* provider.70*71*<h1>Exceptions</h1>72* All the methods in this interface can throw a <tt>NamingException</tt> or73* any of its subclasses. See <tt>NamingException</tt> and their subclasses74* for details on each exception.75*76*<h1>Concurrent Access</h1>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) <tt>lookup</tt>}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 <tt>NamingEnumeration</tt> 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*<h1>Parameters</h1>94* A <tt>Name</tt> parameter passed to any method of the95* <tt>Context</tt> 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 <tt>Name</tt> 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*<h1>Environment Properties</h1>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 <tt>Context</tt> 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 name=RESOURCEFILES></a>140*<h1>Resource Files</h1>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 <tt>java.util.Properties</tt>}),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* <h2>Provider Resource Files</h2>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>/]<tt>jndiprovider.properties</tt>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 <tt>com.sun.jndi.ldap.LdapCtx</tt>.180* The provider resource for this provider is named181* <tt>com/sun/jndi/ldap/jndiprovider.properties</tt>. If the class is182* not in a package, the resource's name is simply183* <tt>jndiprovider.properties</tt>.184*185* <p>186* <a name=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* <h2>Application Resource Files</h2>203*204* When an application is deployed, it will generally have several205* codebase directories and JARs in its classpath. Similarly, when an206* applet is deployed, it will have a codebase and archives specifying207* where to find the applet's classes. JNDI locates (using208* {@link ClassLoader#getResources <tt>ClassLoader.getResources()</tt>})209* all <em>application resource files</em> named <tt>jndi.properties</tt>210* in the classpath.211* In addition, if the file <i>java.home</i><tt>/lib/jndi.properties</tt>212* exists and is readable,213* JNDI treats it as an additional application resource file.214* (<i>java.home</i> indicates the215* directory named by the <tt>java.home</tt> system property.)216* All of the properties contained in these files are placed217* into the environment of the initial context. This environment218* is then inherited by other contexts.219*220* <p>221* For each property found in more than one application resource file,222* JNDI uses the first value found or, in a few cases where it makes223* sense to do so, it concatenates all of the values (details are given224* below).225* For example, if the "java.naming.factory.object" property is found in226* three <tt>jndi.properties</tt> resource files, the227* list of object factories is a concatenation of the property228* values from all three files.229* Using this scheme, each deployable component is responsible for230* listing the factories that it exports. JNDI automatically231* collects and uses all of these export lists when searching for factory232* classes.233*234* <h2>Search Algorithm for Properties</h2>235*236* When JNDI constructs an initial context, the context's environment237* is initialized with properties defined in the environment parameter238* passed to the constructor, the system properties, the applet parameters,239* and the application resource files. See240* <a href=InitialContext.html#ENVIRONMENT><tt>InitialContext</tt></a>241* for details.242* This initial environment is then inherited by other context instances.243*244* <p>245* When the JNDI class library needs to determine246* the value of a property, it does so by merging247* the values from the following two sources, in order:248* <ol>249* <li>The environment of the context being operated on.250* <li>The provider resource file (<tt>jndiprovider.properties</tt>)251* for the context being operated on.252* </ol>253* For each property found in both of these two sources,254* JNDI determines the property's value as follows. If the property is255* one of the standard JNDI properties that specify a list of JNDI256* factories (listed <a href=#LISTPROPS>above</a>), the values are257* concatenated into a single colon-separated list. For other258* properties, only the first value found is used.259*260* <p>261* When a service provider needs to determine the value of a property,262* it will generally take that value directly from the environment.263* A service provider may define provider-specific properties264* to be placed in its own provider resource file. In that265* case it should merge values as described in the previous paragraph.266*267* <p>268* In this way, each service provider developer can specify a list of269* factories to use with that service provider. These can be modified by270* the application resources specified by the deployer of the application271* or applet, which in turn can be modified by the user.272*273* @author Rosanna Lee274* @author Scott Seligman275* @author R. Vasudevan276*277* @since 1.3278*/279280public interface Context {281282/**283* Retrieves the named object.284* If <tt>name</tt> is empty, returns a new instance of this context285* (which represents the same naming context as this context, but its286* environment may be modified independently and it may be accessed287* concurrently).288*289* @param name290* the name of the object to look up291* @return the object bound to <tt>name</tt>292* @throws NamingException if a naming exception is encountered293*294* @see #lookup(String)295* @see #lookupLink(Name)296*/297public Object lookup(Name name) throws NamingException;298299/**300* Retrieves the named object.301* See {@link #lookup(Name)} for details.302* @param name303* the name of the object to look up304* @return the object bound to <tt>name</tt>305* @throws NamingException if a naming exception is encountered306*/307public Object lookup(String name) throws NamingException;308309/**310* Binds a name to an object.311* All intermediate contexts and the target context (that named by all312* but terminal atomic component of the name) must already exist.313*314* @param name315* the name to bind; may not be empty316* @param obj317* the object to bind; possibly null318* @throws NameAlreadyBoundException if name is already bound319* @throws javax.naming.directory.InvalidAttributesException320* if object did not supply all mandatory attributes321* @throws NamingException if a naming exception is encountered322*323* @see #bind(String, Object)324* @see #rebind(Name, Object)325* @see javax.naming.directory.DirContext#bind(Name, Object,326* javax.naming.directory.Attributes)327*/328public void bind(Name name, Object obj) throws NamingException;329330/**331* Binds a name to an object.332* See {@link #bind(Name, Object)} for details.333*334* @param name335* the name to bind; may not be empty336* @param obj337* the object to bind; possibly null338* @throws NameAlreadyBoundException if name is already bound339* @throws javax.naming.directory.InvalidAttributesException340* if object did not supply all mandatory attributes341* @throws NamingException if a naming exception is encountered342*/343public void bind(String name, Object obj) throws NamingException;344345/**346* Binds a name to an object, overwriting any existing binding.347* All intermediate contexts and the target context (that named by all348* but terminal atomic component of the name) must already exist.349*350* <p> If the object is a <tt>DirContext</tt>, any existing attributes351* associated with the name are replaced with those of the object.352* Otherwise, any existing attributes associated with the name remain353* unchanged.354*355* @param name356* the name to bind; may not be empty357* @param obj358* the object to bind; possibly null359* @throws javax.naming.directory.InvalidAttributesException360* if object did not supply all mandatory attributes361* @throws NamingException if a naming exception is encountered362*363* @see #rebind(String, Object)364* @see #bind(Name, Object)365* @see javax.naming.directory.DirContext#rebind(Name, Object,366* javax.naming.directory.Attributes)367* @see javax.naming.directory.DirContext368*/369public void rebind(Name name, Object obj) throws NamingException;370371/**372* Binds a name to an object, overwriting any existing binding.373* See {@link #rebind(Name, Object)} for details.374*375* @param name376* the name to bind; may not be empty377* @param obj378* the object to bind; possibly null379* @throws javax.naming.directory.InvalidAttributesException380* if object did not supply all mandatory attributes381* @throws NamingException if a naming exception is encountered382*/383public void rebind(String name, Object obj) throws NamingException;384385/**386* Unbinds the named object.387* Removes the terminal atomic name in <code>name</code>388* from the target context--that named by all but the terminal389* atomic part of <code>name</code>.390*391* <p> This method is idempotent.392* It succeeds even if the terminal atomic name393* is not bound in the target context, but throws394* <tt>NameNotFoundException</tt>395* if any of the intermediate contexts do not exist.396*397* <p> Any attributes associated with the name are removed.398* Intermediate contexts are not changed.399*400* @param name401* the name to unbind; may not be empty402* @throws NameNotFoundException if an intermediate context does not exist403* @throws NamingException if a naming exception is encountered404* @see #unbind(String)405*/406public void unbind(Name name) throws NamingException;407408/**409* Unbinds the named object.410* See {@link #unbind(Name)} for details.411*412* @param name413* the name to unbind; may not be empty414* @throws NameNotFoundException if an intermediate context does not exist415* @throws NamingException if a naming exception is encountered416*/417public void unbind(String name) throws NamingException;418419/**420* Binds a new name to the object bound to an old name, and unbinds421* the old name. Both names are relative to this context.422* Any attributes associated with the old name become associated423* with the new name.424* Intermediate contexts of the old name are not changed.425*426* @param oldName427* the name of the existing binding; may not be empty428* @param newName429* the name of the new binding; may not be empty430* @throws NameAlreadyBoundException if <tt>newName</tt> is already bound431* @throws NamingException if a naming exception is encountered432*433* @see #rename(String, String)434* @see #bind(Name, Object)435* @see #rebind(Name, Object)436*/437public void rename(Name oldName, Name newName) throws NamingException;438439/**440* Binds a new name to the object bound to an old name, and unbinds441* the old name.442* See {@link #rename(Name, Name)} for details.443*444* @param oldName445* the name of the existing binding; may not be empty446* @param newName447* the name of the new binding; may not be empty448* @throws NameAlreadyBoundException if <tt>newName</tt> is already bound449* @throws NamingException if a naming exception is encountered450*/451public void rename(String oldName, String newName) throws NamingException;452453/**454* Enumerates the names bound in the named context, along with the455* class names of objects bound to them.456* The contents of any subcontexts are not included.457*458* <p> If a binding is added to or removed from this context,459* its effect on an enumeration previously returned is undefined.460*461* @param name462* the name of the context to list463* @return an enumeration of the names and class names of the464* bindings in this context. Each element of the465* enumeration is of type <tt>NameClassPair</tt>.466* @throws NamingException if a naming exception is encountered467*468* @see #list(String)469* @see #listBindings(Name)470* @see NameClassPair471*/472public NamingEnumeration<NameClassPair> list(Name name)473throws NamingException;474475/**476* Enumerates the names bound in the named context, along with the477* class names of objects bound to them.478* See {@link #list(Name)} for details.479*480* @param name481* the name of the context to list482* @return an enumeration of the names and class names of the483* bindings in this context. Each element of the484* enumeration is of type <tt>NameClassPair</tt>.485* @throws NamingException if a naming exception is encountered486*/487public NamingEnumeration<NameClassPair> list(String name)488throws NamingException;489490/**491* Enumerates the names bound in the named context, along with the492* objects bound to them.493* The contents of any subcontexts are not included.494*495* <p> If a binding is added to or removed from this context,496* its effect on an enumeration previously returned is undefined.497*498* @param name499* the name of the context to list500* @return an enumeration of the bindings in this context.501* Each element of the enumeration is of type502* <tt>Binding</tt>.503* @throws NamingException if a naming exception is encountered504*505* @see #listBindings(String)506* @see #list(Name)507* @see Binding508*/509public NamingEnumeration<Binding> listBindings(Name name)510throws NamingException;511512/**513* Enumerates the names bound in the named context, along with the514* objects bound to them.515* See {@link #listBindings(Name)} for details.516*517* @param name518* the name of the context to list519* @return an enumeration of the bindings in this context.520* Each element of the enumeration is of type521* <tt>Binding</tt>.522* @throws NamingException if a naming exception is encountered523*/524public NamingEnumeration<Binding> listBindings(String name)525throws NamingException;526527/**528* Destroys the named context and removes it from the namespace.529* Any attributes associated with the name are also removed.530* Intermediate contexts are not destroyed.531*532* <p> This method is idempotent.533* It succeeds even if the terminal atomic name534* is not bound in the target context, but throws535* <tt>NameNotFoundException</tt>536* if any of the intermediate contexts do not exist.537*538* <p> In a federated naming system, a context from one naming system539* may be bound to a name in another. One can subsequently540* look up and perform operations on the foreign context using a541* composite name. However, an attempt destroy the context using542* this composite name will fail with543* <tt>NotContextException</tt>, because the foreign context is not544* a "subcontext" of the context in which it is bound.545* Instead, use <tt>unbind()</tt> to remove the546* binding of the foreign context. Destroying the foreign context547* requires that the <tt>destroySubcontext()</tt> be performed548* on a context from the foreign context's "native" naming system.549*550* @param name551* the name of the context to be destroyed; may not be empty552* @throws NameNotFoundException if an intermediate context does not exist553* @throws NotContextException if the name is bound but does not name a554* context, or does not name a context of the appropriate type555* @throws ContextNotEmptyException if the named context is not empty556* @throws NamingException if a naming exception is encountered557*558* @see #destroySubcontext(String)559*/560public void destroySubcontext(Name name) throws NamingException;561562/**563* Destroys the named context and removes it from the namespace.564* See {@link #destroySubcontext(Name)} for details.565*566* @param name567* the name of the context to be destroyed; may not be empty568* @throws NameNotFoundException if an intermediate context does not exist569* @throws NotContextException if the name is bound but does not name a570* context, or does not name a context of the appropriate type571* @throws ContextNotEmptyException if the named context is not empty572* @throws NamingException if a naming exception is encountered573*/574public void destroySubcontext(String name) throws NamingException;575576/**577* Creates and binds a new context.578* Creates a new context with the given name and binds it in579* the target context (that named by all but terminal atomic580* component of the name). All intermediate contexts and the581* target context must already exist.582*583* @param name584* the name of the context to create; may not be empty585* @return the newly created context586*587* @throws NameAlreadyBoundException if name is already bound588* @throws javax.naming.directory.InvalidAttributesException589* if creation of the subcontext requires specification of590* mandatory attributes591* @throws NamingException if a naming exception is encountered592*593* @see #createSubcontext(String)594* @see javax.naming.directory.DirContext#createSubcontext595*/596public Context createSubcontext(Name name) throws NamingException;597598/**599* Creates and binds a new context.600* See {@link #createSubcontext(Name)} for details.601*602* @param name603* the name of the context to create; may not be empty604* @return the newly created context605*606* @throws NameAlreadyBoundException if name is already bound607* @throws javax.naming.directory.InvalidAttributesException608* if creation of the subcontext requires specification of609* mandatory attributes610* @throws NamingException if a naming exception is encountered611*/612public Context createSubcontext(String name) throws NamingException;613614/**615* Retrieves the named object, following links except616* for the terminal atomic component of the name.617* If the object bound to <tt>name</tt> is not a link,618* returns the object itself.619*620* @param name621* the name of the object to look up622* @return the object bound to <tt>name</tt>, not following the623* terminal link (if any).624* @throws NamingException if a naming exception is encountered625*626* @see #lookupLink(String)627*/628public Object lookupLink(Name name) throws NamingException;629630/**631* Retrieves the named object, following links except632* for the terminal atomic component of the name.633* See {@link #lookupLink(Name)} for details.634*635* @param name636* the name of the object to look up637* @return the object bound to <tt>name</tt>, not following the638* terminal link (if any)639* @throws NamingException if a naming exception is encountered640*/641public Object lookupLink(String name) throws NamingException;642643/**644* Retrieves the parser associated with the named context.645* In a federation of namespaces, different naming systems will646* parse names differently. This method allows an application647* to get a parser for parsing names into their atomic components648* using the naming convention of a particular naming system.649* Within any single naming system, <tt>NameParser</tt> objects650* returned by this method must be equal (using the <tt>equals()</tt>651* test).652*653* @param name654* the name of the context from which to get the parser655* @return a name parser that can parse compound names into their atomic656* components657* @throws NamingException if a naming exception is encountered658*659* @see #getNameParser(String)660* @see CompoundName661*/662public NameParser getNameParser(Name name) throws NamingException;663664/**665* Retrieves the parser associated with the named context.666* See {@link #getNameParser(Name)} for details.667*668* @param name669* the name of the context from which to get the parser670* @return a name parser that can parse compound names into their atomic671* components672* @throws NamingException if a naming exception is encountered673*/674public NameParser getNameParser(String name) throws NamingException;675676/**677* Composes the name of this context with a name relative to678* this context.679* Given a name (<code>name</code>) relative to this context, and680* the name (<code>prefix</code>) of this context relative to one681* of its ancestors, this method returns the composition of the682* two names using the syntax appropriate for the naming683* system(s) involved. That is, if <code>name</code> names an684* object relative to this context, the result is the name of the685* same object, but relative to the ancestor context. None of the686* names may be null.687* <p>688* For example, if this context is named "wiz.com" relative689* to the initial context, then690* <pre>691* composeName("east", "wiz.com") </pre>692* might return <code>"east.wiz.com"</code>.693* If instead this context is named "org/research", then694* <pre>695* composeName("user/jane", "org/research") </pre>696* might return <code>"org/research/user/jane"</code> while697* <pre>698* composeName("user/jane", "research") </pre>699* returns <code>"research/user/jane"</code>.700*701* @param name702* a name relative to this context703* @param prefix704* the name of this context relative to one of its ancestors705* @return the composition of <code>prefix</code> and <code>name</code>706* @throws NamingException if a naming exception is encountered707*708* @see #composeName(String, String)709*/710public Name composeName(Name name, Name prefix)711throws NamingException;712713/**714* Composes the name of this context with a name relative to715* this context.716* See {@link #composeName(Name, Name)} for details.717*718* @param name719* a name relative to this context720* @param prefix721* the name of this context relative to one of its ancestors722* @return the composition of <code>prefix</code> and <code>name</code>723* @throws NamingException if a naming exception is encountered724*/725public String composeName(String name, String prefix)726throws NamingException;727728/**729* Adds a new environment property to the environment of this730* context. If the property already exists, its value is overwritten.731* See class description for more details on environment properties.732*733* @param propName734* the name of the environment property to add; may not be null735* @param propVal736* the value of the property to add; may not be null737* @return the previous value of the property, or null if the property was738* not in the environment before739* @throws NamingException if a naming exception is encountered740*741* @see #getEnvironment()742* @see #removeFromEnvironment(String)743*/744public Object addToEnvironment(String propName, Object propVal)745throws NamingException;746747/**748* Removes an environment property from the environment of this749* context. See class description for more details on environment750* properties.751*752* @param propName753* the name of the environment property to remove; may not be null754* @return the previous value of the property, or null if the property was755* not in the environment756* @throws NamingException if a naming exception is encountered757*758* @see #getEnvironment()759* @see #addToEnvironment(String, Object)760*/761public Object removeFromEnvironment(String propName)762throws NamingException;763764/**765* Retrieves the environment in effect for this context.766* See class description for more details on environment properties.767*768* <p> The caller should not make any changes to the object returned:769* their effect on the context is undefined.770* The environment of this context may be changed using771* <tt>addToEnvironment()</tt> and <tt>removeFromEnvironment()</tt>.772*773* @return the environment of this context; never null774* @throws NamingException if a naming exception is encountered775*776* @see #addToEnvironment(String, Object)777* @see #removeFromEnvironment(String)778*/779public Hashtable<?,?> getEnvironment() throws NamingException;780781/**782* Closes this context.783* This method releases this context's resources immediately, instead of784* waiting for them to be released automatically by the garbage collector.785*786* <p> This method is idempotent: invoking it on a context that has787* already been closed has no effect. Invoking any other method788* on a closed context is not allowed, and results in undefined behaviour.789*790* @throws NamingException if a naming exception is encountered791*/792public void close() throws NamingException;793794/**795* Retrieves the full name of this context within its own namespace.796*797* <p> Many naming services have a notion of a "full name" for objects798* in their respective namespaces. For example, an LDAP entry has799* a distinguished name, and a DNS record has a fully qualified name.800* This method allows the client application to retrieve this name.801* The string returned by this method is not a JNDI composite name802* and should not be passed directly to context methods.803* In naming systems for which the notion of full name does not804* make sense, <tt>OperationNotSupportedException</tt> is thrown.805*806* @return this context's name in its own namespace; never null807* @throws OperationNotSupportedException if the naming system does808* not have the notion of a full name809* @throws NamingException if a naming exception is encountered810*811* @since 1.3812*/813public String getNameInNamespace() throws NamingException;814815// public static final: JLS says recommended style is to omit these modifiers816// because they are the default817818/**819* Constant that holds the name of the environment property820* for specifying the initial context factory to use. The value821* of the property should be the fully qualified class name822* of the factory class that will create an initial context.823* This property may be specified in the environment parameter824* passed to the initial context constructor, an applet parameter,825* a system property, or an application resource file.826* If it is not specified in any of these sources,827* <tt>NoInitialContextException</tt> is thrown when an initial828* context is required to complete an operation.829*830* <p> The value of this constant is "java.naming.factory.initial".831*832* @see InitialContext833* @see javax.naming.directory.InitialDirContext834* @see javax.naming.spi.NamingManager#getInitialContext835* @see javax.naming.spi.InitialContextFactory836* @see NoInitialContextException837* @see #addToEnvironment(String, Object)838* @see #removeFromEnvironment(String)839* @see #APPLET840*/841String INITIAL_CONTEXT_FACTORY = "java.naming.factory.initial";842843/**844* Constant that holds the name of the environment property845* for specifying the list of object factories to use. The value846* of the property should be a colon-separated list of the fully847* qualified class names of factory classes that will create an object848* given information about the object.849* This property may be specified in the environment, an applet850* parameter, a system property, or one or more resource files.851*852* <p> The value of this constant is "java.naming.factory.object".853*854* @see javax.naming.spi.NamingManager#getObjectInstance855* @see javax.naming.spi.ObjectFactory856* @see #addToEnvironment(String, Object)857* @see #removeFromEnvironment(String)858* @see #APPLET859*/860String OBJECT_FACTORIES = "java.naming.factory.object";861862/**863* Constant that holds the name of the environment property864* for specifying the list of state factories to use. The value865* of the property should be a colon-separated list of the fully866* qualified class names of state factory classes that will be used867* to get an object's state given the object itself.868* This property may be specified in the environment, an applet869* parameter, a system property, or one or more resource files.870*871* <p> The value of this constant is "java.naming.factory.state".872*873* @see javax.naming.spi.NamingManager#getStateToBind874* @see javax.naming.spi.StateFactory875* @see #addToEnvironment(String, Object)876* @see #removeFromEnvironment(String)877* @see #APPLET878* @since 1.3879*/880String STATE_FACTORIES = "java.naming.factory.state";881882/**883* Constant that holds the name of the environment property884* for specifying the list of package prefixes to use when885* loading in URL context factories. The value886* of the property should be a colon-separated list of package887* prefixes for the class name of the factory class that will create888* a URL context factory.889* This property may be specified in the environment,890* an applet parameter, a system property, or one or more891* resource files.892* The prefix <tt>com.sun.jndi.url</tt> is always appended to893* the possibly empty list of package prefixes.894*895* <p> The value of this constant is "java.naming.factory.url.pkgs".896*897* @see javax.naming.spi.NamingManager#getObjectInstance898* @see javax.naming.spi.NamingManager#getURLContext899* @see javax.naming.spi.ObjectFactory900* @see #addToEnvironment(String, Object)901* @see #removeFromEnvironment(String)902* @see #APPLET903*/904String URL_PKG_PREFIXES = "java.naming.factory.url.pkgs";905906/**907* Constant that holds the name of the environment property908* for specifying configuration information for the service provider909* to use. The value of the property should contain a URL string910* (e.g. "ldap://somehost:389").911* This property may be specified in the environment,912* an applet parameter, a system property, or a resource file.913* If it is not specified in any of these sources,914* the default configuration is determined by the service provider.915*916* <p> The value of this constant is "java.naming.provider.url".917*918* @see #addToEnvironment(String, Object)919* @see #removeFromEnvironment(String)920* @see #APPLET921*/922String PROVIDER_URL = "java.naming.provider.url";923924/**925* Constant that holds the name of the environment property926* for specifying the DNS host and domain names to use for the927* JNDI URL context (for example, "dns://somehost/wiz.com").928* This property may be specified in the environment,929* an applet parameter, a system property, or a resource file.930* If it is not specified in any of these sources931* and the program attempts to use a JNDI URL containing a DNS name,932* a <tt>ConfigurationException</tt> will be thrown.933*934* <p> The value of this constant is "java.naming.dns.url".935*936* @see #addToEnvironment(String, Object)937* @see #removeFromEnvironment(String)938*/939String DNS_URL = "java.naming.dns.url";940941/**942* Constant that holds the name of the environment property for943* specifying the authoritativeness of the service requested.944* If the value of the property is the string "true", it means945* that the access is to the most authoritative source (i.e. bypass946* any cache or replicas). If the value is anything else,947* the source need not be (but may be) authoritative.948* If unspecified, the value defaults to "false".949*950* <p> The value of this constant is "java.naming.authoritative".951*952* @see #addToEnvironment(String, Object)953* @see #removeFromEnvironment(String)954*/955String AUTHORITATIVE = "java.naming.authoritative";956957/**958* Constant that holds the name of the environment property for959* specifying the batch size to use when returning data via the960* service's protocol. This is a hint to the provider to return961* the results of operations in batches of the specified size, so962* the provider can optimize its performance and usage of resources.963* The value of the property is the string representation of an964* integer.965* If unspecified, the batch size is determined by the service966* provider.967*968* <p> The value of this constant is "java.naming.batchsize".969*970* @see #addToEnvironment(String, Object)971* @see #removeFromEnvironment(String)972*/973String BATCHSIZE = "java.naming.batchsize";974975/**976* Constant that holds the name of the environment property for977* specifying how referrals encountered by the service provider978* are to be processed. The value of the property is one of the979* following strings:980* <dl>981* <dt>"follow"982* <dd>follow referrals automatically983* <dt>"ignore"984* <dd>ignore referrals985* <dt>"throw"986* <dd>throw <tt>ReferralException</tt> when a referral is encountered.987* </dl>988* If this property is not specified, the default is989* determined by the provider.990*991* <p> The value of this constant is "java.naming.referral".992*993* @see #addToEnvironment(String, Object)994* @see #removeFromEnvironment(String)995*/996String REFERRAL = "java.naming.referral";997998/**999* Constant that holds the name of the environment property for1000* specifying the security protocol to use.1001* Its value is a string determined by the service provider1002* (e.g. "ssl").1003* If this property is unspecified,1004* the behaviour is determined by the service provider.1005*1006* <p> The value of this constant is "java.naming.security.protocol".1007*1008* @see #addToEnvironment(String, Object)1009* @see #removeFromEnvironment(String)1010*/1011String SECURITY_PROTOCOL = "java.naming.security.protocol";10121013/**1014* Constant that holds the name of the environment property for1015* specifying the security level to use.1016* Its value is one of the following strings:1017* "none", "simple", "strong".1018* If this property is unspecified,1019* the behaviour is determined by the service provider.1020*1021* <p> The value of this constant is "java.naming.security.authentication".1022*1023* @see #addToEnvironment(String, Object)1024* @see #removeFromEnvironment(String)1025*/1026String SECURITY_AUTHENTICATION = "java.naming.security.authentication";10271028/**1029* Constant that holds the name of the environment property for1030* specifying the identity of the principal for authenticating1031* the caller to the service. The format of the principal1032* depends on the authentication scheme.1033* If this property is unspecified,1034* the behaviour is determined by the service provider.1035*1036* <p> The value of this constant is "java.naming.security.principal".1037*1038* @see #addToEnvironment(String, Object)1039* @see #removeFromEnvironment(String)1040*/1041String SECURITY_PRINCIPAL = "java.naming.security.principal";10421043/**1044* Constant that holds the name of the environment property for1045* specifying the credentials of the principal for authenticating1046* the caller to the service. The value of the property depends1047* on the authentication scheme. For example, it could be a hashed1048* password, clear-text password, key, certificate, and so on.1049* If this property is unspecified,1050* the behaviour is determined by the service provider.1051*1052* <p> The value of this constant is "java.naming.security.credentials".1053*1054* @see #addToEnvironment(String, Object)1055* @see #removeFromEnvironment(String)1056*/10571058String SECURITY_CREDENTIALS = "java.naming.security.credentials";1059/**1060* Constant that holds the name of the environment property for1061* specifying the preferred language to use with the service.1062* The value of the property is a colon-separated list of language1063* tags as defined in RFC 1766.1064* If this property is unspecified,1065* the language preference is determined by the service provider.1066*1067* <p> The value of this constant is "java.naming.language".1068*1069* @see #addToEnvironment(String, Object)1070* @see #removeFromEnvironment(String)1071*/1072String LANGUAGE = "java.naming.language";10731074/**1075* Constant that holds the name of the environment property for1076* specifying an applet for the initial context constructor to use1077* when searching for other properties.1078* The value of this property is the1079* <tt>java.applet.Applet</tt> instance that is being executed.1080* This property may be specified in the environment parameter1081* passed to the initial context constructor.1082* When this property is set, each property that the initial context1083* constructor looks for in the system properties is first looked for1084* in the applet's parameter list.1085* If this property is unspecified, the initial context constructor1086* will search for properties only in the environment parameter1087* passed to it, the system properties, and application resource files.1088*1089* <p> The value of this constant is "java.naming.applet".1090*1091* @see #addToEnvironment(String, Object)1092* @see #removeFromEnvironment(String)1093* @see InitialContext1094*1095* @since 1.31096*/1097String APPLET = "java.naming.applet";1098};109911001101