1. /*
  2. * @(#)Context.java 1.9 03/01/23
  3. *
  4. * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
  5. * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
  6. */
  7. package javax.naming;
  8. import java.util.Hashtable;
  9. /**
  10. * This interface represents a naming context, which
  11. * consists of a set of name-to-object bindings.
  12. * It contains methods for examining and updating these bindings.
  13. * <p>
  14. * <h4>Names</h4>
  15. * Each name passed as an argument to a <tt>Context</tt> method is relative
  16. * to that context. The empty name is used to name the context itself.
  17. * A name parameter may never be null.
  18. * <p>
  19. * Most of the methods have overloaded versions with one taking a
  20. * <code>Name</code> parameter and one taking a <code>String</code>.
  21. * These overloaded versions are equivalent in that if
  22. * the <code>Name</code> and <code>String</code> parameters are just
  23. * different representations of the same name, then the overloaded
  24. * versions of the same methods behave the same.
  25. * In the method descriptions below, only one version is fully documented.
  26. * The second version instead has a link to the first: the same
  27. * documentation applies to both.
  28. * <p>
  29. * For systems that support federation, <tt>String</tt> name arguments to
  30. * <tt>Context</tt> methods are composite names. Name arguments that are
  31. * instances of <tt>CompositeName</tt> are treated as composite names,
  32. * while <tt>Name</tt> arguments that are not instances of
  33. * <tt>CompositeName</tt> are treated as compound names (which might be
  34. * instances of <tt>CompoundName</tt> or other implementations of compound
  35. * names). This allows the results of <tt>NameParser.parse()</tt> to be used as
  36. * arguments to the <tt>Context</tt> methods.
  37. * Prior to JNDI 1.2, all name arguments were treated as composite names.
  38. *<p>
  39. * Furthermore, for systems that support federation, all names returned
  40. * in a <tt>NamingEnumeration</tt>
  41. * from <tt>list()</tt> and <tt>listBindings()</tt> are composite names
  42. * represented as strings.
  43. * See <tt>CompositeName</tt> for the string syntax of names.
  44. *<p>
  45. * For systems that do not support federation, the name arguments (in
  46. * either <tt>Name</tt> or <tt>String</tt> forms) and the names returned in
  47. * <tt>NamingEnumeration</tt> may be names in their own namespace rather than
  48. * names in a composite namespace, at the discretion of the service
  49. * provider.
  50. *<p>
  51. *<h4>Exceptions</h4>
  52. * All the methods in this interface can throw a <tt>NamingException</tt> or
  53. * any of its subclasses. See <tt>NamingException</tt> and their subclasses
  54. * for details on each exception.
  55. *<p>
  56. *<h4>Concurrent Access</h4>
  57. * A Context instance is not guaranteed to be synchronized against
  58. * concurrent access by multiple threads. Threads that need to access
  59. * a single Context instance concurrently should synchronize amongst
  60. * themselves and provide the necessary locking. Multiple threads
  61. * each manipulating a different Context instance need not
  62. * synchronize. Note that the {@link #lookup(Name) <tt>lookup</tt>}
  63. * method, when passed an empty name, will return a new Context instance
  64. * representing the same naming context.
  65. *<p>
  66. * For purposes of concurrency control,
  67. * a Context operation that returns a <tt>NamingEnumeration</tt> is
  68. * not considered to have completed while the enumeration is still in
  69. * use, or while any referrals generated by that operation are still
  70. * being followed.
  71. *
  72. *<p>
  73. *<h4>Parameters</h4>
  74. * A <tt>Name</tt> parameter passed to any method of the
  75. * <tt>Context</tt> interface or one of its subinterfaces
  76. * will not be modified by the service provider.
  77. * The service provider may keep a reference to it
  78. * for the duration of the operation, including any enumeration of the
  79. * method's results and the processing of any referrals generated.
  80. * The caller should not modify the object during this time.
  81. * A <tt>Name</tt> returned by any such method is owned by the caller.
  82. * The caller may subsequently modify it; the service provider may not.
  83. *
  84. *<p>
  85. *<h4>Environment Properties</h4>
  86. *<p>
  87. * JNDI applications need a way to communicate various preferences
  88. * and properties that define the environment in which naming and
  89. * directory services are accessed. For example, a context might
  90. * require specification of security credentials in order to access
  91. * the service. Another context might require that server configuration
  92. * information be supplied. These are referred to as the <em>environment</em>
  93. * of a context. The <tt>Context</tt> interface provides methods for
  94. * retrieving and updating this environment.
  95. *<p>
  96. * The environment is inherited from the parent context as
  97. * context methods proceed from one context to the next. Changes to
  98. * the environment of one context do not directly affect those
  99. * of other contexts.
  100. *<p>
  101. * It is implementation-dependent when environment properties are used
  102. * and/or verified for validity. For example, some of the
  103. * security-related properties are used by service providers to "log in"
  104. * to the directory. This login process might occur at the time the
  105. * context is created, or the first time a method is invoked on the
  106. * context. When, and whether this occurs at all, is
  107. * implementation-dependent. When environment properties are added or
  108. * removed from the context, verifying the validity of the changes is again
  109. * implementation-dependent. For example, verification of some properties
  110. * might occur at the time the change is made, or at the time the next
  111. * operation is performed on the context, or not at all.
  112. *<p>
  113. * Any object with a reference to a context may examine that context's
  114. * environment. Sensitive information such as clear-text
  115. * passwords should not be stored there unless the implementation is
  116. * known to protect it.
  117. *
  118. *<p>
  119. *<a name=RESOURCEFILES></a>
  120. *<h4>Resource Files</h4>
  121. *<p>
  122. * To simplify the task of setting up the environment
  123. * required by a JNDI application,
  124. * application components and service providers may be distributed
  125. * along with <em>resource files.</em>
  126. * A JNDI resource file is a file in the properties file format (see
  127. * {@link java.util.Properties#load <tt>java.util.Properties</tt>}),
  128. * containing a list of key/value pairs.
  129. * The key is the name of the property (e.g. "java.naming.factory.object")
  130. * and the value is a string in the format defined
  131. * for that property. Here is an example of a JNDI resource file:
  132. *
  133. * <blockquote><tt><pre>
  134. * java.naming.factory.object=com.sun.jndi.ldap.AttrsToCorba:com.wiz.from.Person
  135. * java.naming.factory.state=com.sun.jndi.ldap.CorbaToAttrs:com.wiz.from.Person
  136. * java.naming.factory.control=com.sun.jndi.ldap.ResponseControlFactory
  137. * </pre></tt></blockquote>
  138. *
  139. * The JNDI class library reads the resource files and makes the property
  140. * values freely available. Thus JNDI resource files should be considered
  141. * to be "world readable", and sensitive information such as clear-text
  142. * passwords should not be stored there.
  143. *<p>
  144. * There are two kinds of JNDI resource files:
  145. * <em>provider</em> and <em>application</em>.
  146. *
  147. * <h5>Provider Resource Files</h5>
  148. *
  149. * Each service provider has an optional resource that lists properties
  150. * specific to that provider. The name of this resource is:
  151. * <blockquote>
  152. * [<em>prefix</em>/]<tt>jndiprovider.properties</tt>
  153. * </blockquote>
  154. * where <em>prefix</em> is
  155. * the package name of the provider's context implementation(s),
  156. * with each period (".") converted to a slash ("/").
  157. *
  158. * For example, suppose a service provider defines a context
  159. * implementation with class name <tt>com.sun.jndi.ldap.LdapCtx</tt>.
  160. * The provider resource for this provider is named
  161. * <tt>com/sun/jndi/ldap/jndiprovider.properties</tt>. If the class is
  162. * not in a package, the resource's name is simply
  163. * <tt>jndiprovider.properties</tt>.
  164. *
  165. * <p>
  166. * <a name=LISTPROPS></a>
  167. * Certain methods in the JNDI class library make use of the standard
  168. * JNDI properties that specify lists of JNDI factories:
  169. * <ul>
  170. * <li>java.naming.factory.object
  171. * <li>java.naming.factory.state
  172. * <li>java.naming.factory.control
  173. * <li>java.naming.factory.url.pkgs
  174. * </ul>
  175. * The JNDI library will consult the provider resource file
  176. * when determining the values of these properties.
  177. * Properties other than these may be set in the provider
  178. * resource file at the discretion of the service provider.
  179. * The service provider's documentation should clearly state which
  180. * properties are allowed; other properties in the file will be ignored.
  181. *
  182. * <h5>Application Resource Files</h5>
  183. *
  184. * When an application is deployed, it will generally have several
  185. * codebase directories and JARs in its classpath. Similarly, when an
  186. * applet is deployed, it will have a codebase and archives specifying
  187. * where to find the applet's classes. JNDI locates (using
  188. * {@link ClassLoader#getResources <tt>ClassLoader.getResources()</tt>})
  189. * all <em>application resource files</em> named <tt>jndi.properties</tt>
  190. * in the classpath.
  191. * In addition, if the file <i>java.home</i><tt>/lib/jndi.properties</tt>
  192. * exists and is readable,
  193. * JNDI treats it as an additional application resource file.
  194. * (<i>java.home</i> indicates the
  195. * directory named by the <tt>java.home</tt> system property.)
  196. * All of the properties contained in these files are placed
  197. * into the environment of the initial context. This environment
  198. * is then inherited by other contexts.
  199. *
  200. * <p>
  201. * For each property found in more than one application resource file,
  202. * JNDI uses the first value found or, in a few cases where it makes
  203. * sense to do so, it concatenates all of the values (details are given
  204. * below).
  205. * For example, if the "java.naming.factory.object" property is found in
  206. * three <tt>jndi.properties</tt> resource files, the
  207. * list of object factories is a concatenation of the property
  208. * values from all three files.
  209. * Using this scheme, each deployable component is responsible for
  210. * listing the factories that it exports. JNDI automatically
  211. * collects and uses all of these export lists when searching for factory
  212. * classes.
  213. *
  214. * <p>
  215. * Application resource files are available beginning with the Java 2
  216. * Platform, except that the file in
  217. * <i>java.home</i><tt>/lib</tt> may be used on earlier Java platforms as well.
  218. *
  219. * <h5>Search Algorithm for Properties</h5>
  220. *
  221. * When JNDI constructs an initial context, the context's environment
  222. * is initialized with properties defined in the environment parameter
  223. * passed to the constructor, the system properties, the applet parameters,
  224. * and the application resource files. See
  225. * <a href=InitialContext.html#ENVIRONMENT><tt>InitialContext</tt></a>
  226. * for details.
  227. * This initial environment is then inherited by other context instances.
  228. *
  229. * <p>
  230. * When the JNDI class library needs to determine
  231. * the value of a property, it does so by merging
  232. * the values from the following two sources, in order:
  233. * <ol>
  234. * <li>The environment of the context being operated on.
  235. * <li>The provider resource file (<tt>jndiprovider.properties</tt>)
  236. * for the context being operated on.
  237. * </ol>
  238. * For each property found in both of these two sources,
  239. * JNDI determines the property's value as follows. If the property is
  240. * one of the standard JNDI properties that specify a list of JNDI
  241. * factories (listed <a href=#LISTPROPS>above</a>), the values are
  242. * concatenated into a single colon-separated list. For other
  243. * properties, only the first value found is used.
  244. *
  245. * <p>
  246. * When a service provider needs to determine the value of a property,
  247. * it will generally take that value directly from the environment.
  248. * A service provider may define provider-specific properties
  249. * to be placed in its own provider resource file. In that
  250. * case it should merge values as described in the previous paragraph.
  251. *
  252. * <p>
  253. * In this way, each service provider developer can specify a list of
  254. * factories to use with that service provider. These can be modified by
  255. * the application resources specified by the deployer of the application
  256. * or applet, which in turn can be modified by the user.
  257. *
  258. * @author Rosanna Lee
  259. * @author Scott Seligman
  260. * @author R. Vasudevan
  261. * @version 1.9 03/01/23
  262. *
  263. * @since 1.3
  264. */
  265. public interface Context {
  266. /**
  267. * Retrieves the named object.
  268. * If <tt>name</tt> is empty, returns a new instance of this context
  269. * (which represents the same naming context as this context, but its
  270. * environment may be modified independently and it may be accessed
  271. * concurrently).
  272. *
  273. * @param name
  274. * the name of the object to look up
  275. * @return the object bound to <tt>name</tt>
  276. * @throws NamingException if a naming exception is encountered
  277. *
  278. * @see #lookup(String)
  279. * @see #lookupLink(Name)
  280. */
  281. public Object lookup(Name name) throws NamingException;
  282. /**
  283. * Retrieves the named object.
  284. * See {@link #lookup(Name)} for details.
  285. * @param name
  286. * the name of the object to look up
  287. * @return the object bound to <tt>name</tt>
  288. * @throws NamingException if a naming exception is encountered
  289. */
  290. public Object lookup(String name) throws NamingException;
  291. /**
  292. * Binds a name to an object.
  293. * All intermediate contexts and the target context (that named by all
  294. * but terminal atomic component of the name) must already exist.
  295. *
  296. * @param name
  297. * the name to bind; may not be empty
  298. * @param obj
  299. * the object to bind; possibly null
  300. * @throws NameAlreadyBoundException if name is already bound
  301. * @throws javax.naming.directory.InvalidAttributesException
  302. * if object did not supply all mandatory attributes
  303. * @throws NamingException if a naming exception is encountered
  304. *
  305. * @see #bind(String, Object)
  306. * @see #rebind(Name, Object)
  307. * @see javax.naming.directory.DirContext#bind(Name, Object,
  308. * javax.naming.directory.Attributes)
  309. */
  310. public void bind(Name name, Object obj) throws NamingException;
  311. /**
  312. * Binds a name to an object.
  313. * See {@link #bind(Name, Object)} for details.
  314. *
  315. * @param name
  316. * the name to bind; may not be empty
  317. * @param obj
  318. * the object to bind; possibly null
  319. * @throws NameAlreadyBoundException if name is already bound
  320. * @throws javax.naming.directory.InvalidAttributesException
  321. * if object did not supply all mandatory attributes
  322. * @throws NamingException if a naming exception is encountered
  323. */
  324. public void bind(String name, Object obj) throws NamingException;
  325. /**
  326. * Binds a name to an object, overwriting any existing binding.
  327. * All intermediate contexts and the target context (that named by all
  328. * but terminal atomic component of the name) must already exist.
  329. *
  330. * <p> If the object is a <tt>DirContext</tt>, any existing attributes
  331. * associated with the name are replaced with those of the object.
  332. * Otherwise, any existing attributes associated with the name remain
  333. * unchanged.
  334. *
  335. * @param name
  336. * the name to bind; may not be empty
  337. * @param obj
  338. * the object to bind; possibly null
  339. * @throws javax.naming.directory.InvalidAttributesException
  340. * if object did not supply all mandatory attributes
  341. * @throws NamingException if a naming exception is encountered
  342. *
  343. * @see #rebind(String, Object)
  344. * @see #bind(Name, Object)
  345. * @see javax.naming.directory.DirContext#rebind(Name, Object,
  346. * javax.naming.directory.Attributes)
  347. * @see javax.naming.directory.DirContext
  348. */
  349. public void rebind(Name name, Object obj) throws NamingException;
  350. /**
  351. * Binds a name to an object, overwriting any existing binding.
  352. * See {@link #rebind(Name, Object)} for details.
  353. *
  354. * @param name
  355. * the name to bind; may not be empty
  356. * @param obj
  357. * the object to bind; possibly null
  358. * @throws javax.naming.directory.InvalidAttributesException
  359. * if object did not supply all mandatory attributes
  360. * @throws NamingException if a naming exception is encountered
  361. */
  362. public void rebind(String name, Object obj) throws NamingException;
  363. /**
  364. * Unbinds the named object.
  365. * Removes the terminal atomic name in <code>name</code>
  366. * from the target context--that named by all but the terminal
  367. * atomic part of <code>name</code>.
  368. *
  369. * <p> This method is idempotent.
  370. * It succeeds even if the terminal atomic name
  371. * is not bound in the target context, but throws
  372. * <tt>NameNotFoundException</tt>
  373. * if any of the intermediate contexts do not exist.
  374. *
  375. * <p> Any attributes associated with the name are removed.
  376. * Intermediate contexts are not changed.
  377. *
  378. * @param name
  379. * the name to unbind; may not be empty
  380. * @throws NameNotFoundException if an intermediate context does not exist
  381. * @throws NamingException if a naming exception is encountered
  382. * @see #unbind(String)
  383. */
  384. public void unbind(Name name) throws NamingException;
  385. /**
  386. * Unbinds the named object.
  387. * See {@link #unbind(Name)} for details.
  388. *
  389. * @param name
  390. * the name to unbind; may not be empty
  391. * @throws NameNotFoundException if an intermediate context does not exist
  392. * @throws NamingException if a naming exception is encountered
  393. */
  394. public void unbind(String name) throws NamingException;
  395. /**
  396. * Binds a new name to the object bound to an old name, and unbinds
  397. * the old name. Both names are relative to this context.
  398. * Any attributes associated with the old name become associated
  399. * with the new name.
  400. * Intermediate contexts of the old name are not changed.
  401. *
  402. * @param oldName
  403. * the name of the existing binding; may not be empty
  404. * @param newName
  405. * the name of the new binding; may not be empty
  406. * @throws NameAlreadyBoundException if <tt>newName</tt> is already bound
  407. * @throws NamingException if a naming exception is encountered
  408. *
  409. * @see #rename(String, String)
  410. * @see #bind(Name, Object)
  411. * @see #rebind(Name, Object)
  412. */
  413. public void rename(Name oldName, Name newName) throws NamingException;
  414. /**
  415. * Binds a new name to the object bound to an old name, and unbinds
  416. * the old name.
  417. * See {@link #rename(Name, Name)} for details.
  418. *
  419. * @param oldName
  420. * the name of the existing binding; may not be empty
  421. * @param newName
  422. * the name of the new binding; may not be empty
  423. * @throws NameAlreadyBoundException if <tt>newName</tt> is already bound
  424. * @throws NamingException if a naming exception is encountered
  425. */
  426. public void rename(String oldName, String newName) throws NamingException;
  427. /**
  428. * Enumerates the names bound in the named context, along with the
  429. * class names of objects bound to them.
  430. * The contents of any subcontexts are not included.
  431. *
  432. * <p> If a binding is added to or removed from this context,
  433. * its effect on an enumeration previously returned is undefined.
  434. *
  435. * @param name
  436. * the name of the context to list
  437. * @return an enumeration of the names and class names of the
  438. * bindings in this context. Each element of the
  439. * enumeration is of type <tt>NameClassPair</tt>.
  440. * @throws NamingException if a naming exception is encountered
  441. *
  442. * @see #list(String)
  443. * @see #listBindings(Name)
  444. * @see NameClassPair
  445. */
  446. public NamingEnumeration list(Name name) throws NamingException;
  447. /**
  448. * Enumerates the names bound in the named context, along with the
  449. * class names of objects bound to them.
  450. * See {@link #list(Name)} for details.
  451. *
  452. * @param name
  453. * the name of the context to list
  454. * @return an enumeration of the names and class names of the
  455. * bindings in this context. Each element of the
  456. * enumeration is of type <tt>NameClassPair</tt>.
  457. * @throws NamingException if a naming exception is encountered
  458. */
  459. public NamingEnumeration list(String name) throws NamingException;
  460. /**
  461. * Enumerates the names bound in the named context, along with the
  462. * objects bound to them.
  463. * The contents of any subcontexts are not included.
  464. *
  465. * <p> If a binding is added to or removed from this context,
  466. * its effect on an enumeration previously returned is undefined.
  467. *
  468. * @param name
  469. * the name of the context to list
  470. * @return an enumeration of the bindings in this context.
  471. * Each element of the enumeration is of type
  472. * <tt>Binding</tt>.
  473. * @throws NamingException if a naming exception is encountered
  474. *
  475. * @see #listBindings(String)
  476. * @see #list(Name)
  477. * @see Binding
  478. */
  479. public NamingEnumeration listBindings(Name name) throws NamingException;
  480. /**
  481. * Enumerates the names bound in the named context, along with the
  482. * objects bound to them.
  483. * See {@link #listBindings(Name)} for details.
  484. *
  485. * @param name
  486. * the name of the context to list
  487. * @return an enumeration of the bindings in this context.
  488. * Each element of the enumeration is of type
  489. * <tt>Binding</tt>.
  490. * @throws NamingException if a naming exception is encountered
  491. */
  492. public NamingEnumeration listBindings(String name) throws NamingException;
  493. /**
  494. * Destroys the named context and removes it from the namespace.
  495. * Any attributes associated with the name are also removed.
  496. * Intermediate contexts are not destroyed.
  497. *
  498. * <p> This method is idempotent.
  499. * It succeeds even if the terminal atomic name
  500. * is not bound in the target context, but throws
  501. * <tt>NameNotFoundException</tt>
  502. * if any of the intermediate contexts do not exist.
  503. *
  504. * <p> In a federated naming system, a context from one naming system
  505. * may be bound to a name in another. One can subsequently
  506. * look up and perform operations on the foreign context using a
  507. * composite name. However, an attempt destroy the context using
  508. * this composite name will fail with
  509. * <tt>NotContextException</tt>, because the foreign context is not
  510. * a "subcontext" of the context in which it is bound.
  511. * Instead, use <tt>unbind()</tt> to remove the
  512. * binding of the foreign context. Destroying the foreign context
  513. * requires that the <tt>destroySubcontext()</tt> be performed
  514. * on a context from the foreign context's "native" naming system.
  515. *
  516. * @param name
  517. * the name of the context to be destroyed; may not be empty
  518. * @throws NameNotFoundException if an intermediate context does not exist
  519. * @throws NotContextException if the name is bound but does not name a
  520. * context, or does not name a context of the appropriate type
  521. * @throws ContextNotEmptyException if the named context is not empty
  522. * @throws NamingException if a naming exception is encountered
  523. *
  524. * @see #destroySubcontext(String)
  525. */
  526. public void destroySubcontext(Name name) throws NamingException;
  527. /**
  528. * Destroys the named context and removes it from the namespace.
  529. * See {@link #destroySubcontext(Name)} for details.
  530. *
  531. * @param name
  532. * the name of the context to be destroyed; may not be empty
  533. * @throws NameNotFoundException if an intermediate context does not exist
  534. * @throws NotContextException if the name is bound but does not name a
  535. * context, or does not name a context of the appropriate type
  536. * @throws ContextNotEmptyException if the named context is not empty
  537. * @throws NamingException if a naming exception is encountered
  538. */
  539. public void destroySubcontext(String name) throws NamingException;
  540. /**
  541. * Creates and binds a new context.
  542. * Creates a new context with the given name and binds it in
  543. * the target context (that named by all but terminal atomic
  544. * component of the name). All intermediate contexts and the
  545. * target context must already exist.
  546. *
  547. * @param name
  548. * the name of the context to create; may not be empty
  549. * @return the newly created context
  550. *
  551. * @throws NameAlreadyBoundException if name is already bound
  552. * @throws javax.naming.directory.InvalidAttributesException
  553. * if creation of the subcontext requires specification of
  554. * mandatory attributes
  555. * @throws NamingException if a naming exception is encountered
  556. *
  557. * @see #createSubcontext(String)
  558. * @see javax.naming.directory.DirContext#createSubcontext
  559. */
  560. public Context createSubcontext(Name name) throws NamingException;
  561. /**
  562. * Creates and binds a new context.
  563. * See {@link #createSubcontext(Name)} for details.
  564. *
  565. * @param name
  566. * the name of the context to create; may not be empty
  567. * @return the newly created context
  568. *
  569. * @throws NameAlreadyBoundException if name is already bound
  570. * @throws javax.naming.directory.InvalidAttributesException
  571. * if creation of the subcontext requires specification of
  572. * mandatory attributes
  573. * @throws NamingException if a naming exception is encountered
  574. */
  575. public Context createSubcontext(String name) throws NamingException;
  576. /**
  577. * Retrieves the named object, following links except
  578. * for the terminal atomic component of the name.
  579. * If the object bound to <tt>name</tt> is not a link,
  580. * returns the object itself.
  581. *
  582. * @param name
  583. * the name of the object to look up
  584. * @return the object bound to <tt>name</tt>, not following the
  585. * terminal link (if any).
  586. * @throws NamingException if a naming exception is encountered
  587. *
  588. * @see #lookupLink(String)
  589. */
  590. public Object lookupLink(Name name) throws NamingException;
  591. /**
  592. * Retrieves the named object, following links except
  593. * for the terminal atomic component of the name.
  594. * See {@link #lookupLink(Name)} for details.
  595. *
  596. * @param name
  597. * the name of the object to look up
  598. * @return the object bound to <tt>name</tt>, not following the
  599. * terminal link (if any)
  600. * @throws NamingException if a naming exception is encountered
  601. */
  602. public Object lookupLink(String name) throws NamingException;
  603. /**
  604. * Retrieves the parser associated with the named context.
  605. * In a federation of namespaces, different naming systems will
  606. * parse names differently. This method allows an application
  607. * to get a parser for parsing names into their atomic components
  608. * using the naming convention of a particular naming system.
  609. * Within any single naming system, <tt>NameParser</tt> objects
  610. * returned by this method must be equal (using the <tt>equals()</tt>
  611. * test).
  612. *
  613. * @param name
  614. * the name of the context from which to get the parser
  615. * @return a name parser that can parse compound names into their atomic
  616. * components
  617. * @throws NamingException if a naming exception is encountered
  618. *
  619. * @see #getNameParser(String)
  620. * @see CompoundName
  621. */
  622. public NameParser getNameParser(Name name) throws NamingException;
  623. /**
  624. * Retrieves the parser associated with the named context.
  625. * See {@link #getNameParser(Name)} for details.
  626. *
  627. * @param name
  628. * the name of the context from which to get the parser
  629. * @return a name parser that can parse compound names into their atomic
  630. * components
  631. * @throws NamingException if a naming exception is encountered
  632. */
  633. public NameParser getNameParser(String name) throws NamingException;
  634. /**
  635. * Composes the name of this context with a name relative to
  636. * this context.
  637. * Given a name (<code>name</code>) relative to this context, and
  638. * the name (<code>prefix</code>) of this context relative to one
  639. * of its ancestors, this method returns the composition of the
  640. * two names using the syntax appropriate for the naming
  641. * system(s) involved. That is, if <code>name</code> names an
  642. * object relative to this context, the result is the name of the
  643. * same object, but relative to the ancestor context. None of the
  644. * names may be null.
  645. * <p>
  646. * For example, if this context is named "wiz.com" relative
  647. * to the initial context, then
  648. * <pre>
  649. * composeName("east", "wiz.com") </pre>
  650. * might return <code>"east.wiz.com"</code>.
  651. * If instead this context is named "org/research", then
  652. * <pre>
  653. * composeName("user/jane", "org/research") </pre>
  654. * might return <code>"org/research/user/jane"</code> while
  655. * <pre>
  656. * composeName("user/jane", "research") </pre>
  657. * returns <code>"research/user/jane"</code>.
  658. *
  659. * @param name
  660. * a name relative to this context
  661. * @param prefix
  662. * the name of this context relative to one of its ancestors
  663. * @return the composition of <code>prefix</code> and <code>name</code>
  664. * @throws NamingException if a naming exception is encountered
  665. *
  666. * @see #composeName(String, String)
  667. */
  668. public Name composeName(Name name, Name prefix) throws NamingException;
  669. /**
  670. * Composes the name of this context with a name relative to
  671. * this context.
  672. * See {@link #composeName(Name, Name)} for details.
  673. *
  674. * @param name
  675. * a name relative to this context
  676. * @param prefix
  677. * the name of this context relative to one of its ancestors
  678. * @return the composition of <code>prefix</code> and <code>name</code>
  679. * @throws NamingException if a naming exception is encountered
  680. */
  681. public String composeName(String name, String prefix)
  682. throws NamingException;
  683. /**
  684. * Adds a new environment property to the environment of this
  685. * context. If the property already exists, its value is overwritten.
  686. * See class description for more details on environment properties.
  687. *
  688. * @param propName
  689. * the name of the environment property to add; may not be null
  690. * @param propVal
  691. * the value of the property to add; may not be null
  692. * @return the previous value of the property, or null if the property was
  693. * not in the environment before
  694. * @throws NamingException if a naming exception is encountered
  695. *
  696. * @see #getEnvironment()
  697. * @see #removeFromEnvironment(String)
  698. */
  699. public Object addToEnvironment(String propName, Object propVal)
  700. throws NamingException;
  701. /**
  702. * Removes an environment property from the environment of this
  703. * context. See class description for more details on environment
  704. * properties.
  705. *
  706. * @param propName
  707. * the name of the environment property to remove; may not be null
  708. * @return the previous value of the property, or null if the property was
  709. * not in the environment
  710. * @throws NamingException if a naming exception is encountered
  711. *
  712. * @see #getEnvironment()
  713. * @see #addToEnvironment(String, Object)
  714. */
  715. public Object removeFromEnvironment(String propName)
  716. throws NamingException;
  717. /**
  718. * Retrieves the environment in effect for this context.
  719. * See class description for more details on environment properties.
  720. *
  721. * <p> The caller should not make any changes to the object returned:
  722. * their effect on the context is undefined.
  723. * The environment of this context may be changed using
  724. * <tt>addToEnvironment()</tt> and <tt>removeFromEnvironment()</tt>.
  725. *
  726. * @return the environment of this context; never null
  727. * @throws NamingException if a naming exception is encountered
  728. *
  729. * @see #addToEnvironment(String, Object)
  730. * @see #removeFromEnvironment(String)
  731. */
  732. public Hashtable getEnvironment() throws NamingException;
  733. /**
  734. * Closes this context.
  735. * This method releases this context's resources immediately, instead of
  736. * waiting for them to be released automatically by the garbage collector.
  737. *
  738. * <p> This method is idempotent: invoking it on a context that has
  739. * already been closed has no effect. Invoking any other method
  740. * on a closed context is not allowed, and results in undefined behaviour.
  741. *
  742. * @throws NamingException if a naming exception is encountered
  743. */
  744. public void close() throws NamingException;
  745. /**
  746. * Retrieves the full name of this context within its own namespace.
  747. *
  748. * <p> Many naming services have a notion of a "full name" for objects
  749. * in their respective namespaces. For example, an LDAP entry has
  750. * a distinguished name, and a DNS record has a fully qualified name.
  751. * This method allows the client application to retrieve this name.
  752. * The string returned by this method is not a JNDI composite name
  753. * and should not be passed directly to context methods.
  754. * In naming systems for which the notion of full name does not
  755. * make sense, <tt>OperationNotSupportedException</tt> is thrown.
  756. *
  757. * @return this context's name in its own namespace; never null
  758. * @throws OperationNotSupportedException if the naming system does
  759. * not have the notion of a full name
  760. * @throws NamingException if a naming exception is encountered
  761. *
  762. * @since 1.3
  763. */
  764. public String getNameInNamespace() throws NamingException;
  765. // public static final: JLS says recommended style is to omit these modifiers
  766. // because they are the default
  767. /**
  768. * Constant that holds the name of the environment property
  769. * for specifying the initial context factory to use. The value
  770. * of the property should be the fully qualified class name
  771. * of the factory class that will create an initial context.
  772. * This property may be specified in the environment parameter
  773. * passed to the initial context constructor, an applet parameter,
  774. * a system property, or an application resource file.
  775. * If it is not specified in any of these sources,
  776. * <tt>NoInitialContextException</tt> is thrown when an initial
  777. * context is required to complete an operation.
  778. *
  779. * <p> The value of this constant is "java.naming.factory.initial".
  780. *
  781. * @see InitialContext
  782. * @see javax.naming.directory.InitialDirContext
  783. * @see javax.naming.spi.NamingManager#getInitialContext
  784. * @see javax.naming.spi.InitialContextFactory
  785. * @see NoInitialContextException
  786. * @see #addToEnvironment(String, Object)
  787. * @see #removeFromEnvironment(String)
  788. * @see #APPLET
  789. */
  790. String INITIAL_CONTEXT_FACTORY = "java.naming.factory.initial";
  791. /**
  792. * Constant that holds the name of the environment property
  793. * for specifying the list of object factories to use. The value
  794. * of the property should be a colon-separated list of the fully
  795. * qualified class names of factory classes that will create an object
  796. * given information about the object.
  797. * This property may be specified in the environment, an applet
  798. * parameter, a system property, or one or more resource files.
  799. *
  800. * <p> The value of this constant is "java.naming.factory.object".
  801. *
  802. * @see javax.naming.spi.NamingManager#getObjectInstance
  803. * @see javax.naming.spi.ObjectFactory
  804. * @see #addToEnvironment(String, Object)
  805. * @see #removeFromEnvironment(String)
  806. * @see #APPLET
  807. */
  808. String OBJECT_FACTORIES = "java.naming.factory.object";
  809. /**
  810. * Constant that holds the name of the environment property
  811. * for specifying the list of state factories to use. The value
  812. * of the property should be a colon-separated list of the fully
  813. * qualified class names of state factory classes that will be used
  814. * to get an object's state given the object itself.
  815. * This property may be specified in the environment, an applet
  816. * parameter, a system property, or one or more resource files.
  817. *
  818. * <p> The value of this constant is "java.naming.factory.state".
  819. *
  820. * @see javax.naming.spi.NamingManager#getStateToBind
  821. * @see javax.naming.spi.StateFactory
  822. * @see #addToEnvironment(String, Object)
  823. * @see #removeFromEnvironment(String)
  824. * @see #APPLET
  825. * @since 1.3
  826. */
  827. String STATE_FACTORIES = "java.naming.factory.state";
  828. /**
  829. * Constant that holds the name of the environment property
  830. * for specifying the list of package prefixes to use when
  831. * loading in URL context factories. The value
  832. * of the property should be a colon-separated list of package
  833. * prefixes for the class name of the factory class that will create
  834. * a URL context factory.
  835. * This property may be specified in the environment,
  836. * an applet parameter, a system property, or one or more
  837. * resource files.
  838. * The prefix <tt>com.sun.jndi.url</tt> is always appended to
  839. * the possibly empty list of package prefixes.
  840. *
  841. * <p> The value of this constant is "java.naming.factory.url.pkgs".
  842. *
  843. * @see javax.naming.spi.NamingManager#getObjectInstance
  844. * @see javax.naming.spi.NamingManager#getURLContext
  845. * @see javax.naming.spi.ObjectFactory
  846. * @see #addToEnvironment(String, Object)
  847. * @see #removeFromEnvironment(String)
  848. * @see #APPLET
  849. */
  850. String URL_PKG_PREFIXES = "java.naming.factory.url.pkgs";
  851. /**
  852. * Constant that holds the name of the environment property
  853. * for specifying configuration information for the service provider
  854. * to use. The value of the property should contain a URL string
  855. * (e.g. "ldap://somehost:389").
  856. * This property may be specified in the environment,
  857. * an applet parameter, a system property, or a resource file.
  858. * If it is not specified in any of these sources,
  859. * the default configuration is determined by the service provider.
  860. *
  861. * <p> The value of this constant is "java.naming.provider.url".
  862. *
  863. * @see #addToEnvironment(String, Object)
  864. * @see #removeFromEnvironment(String)
  865. * @see #APPLET
  866. */
  867. String PROVIDER_URL = "java.naming.provider.url";
  868. /**
  869. * Constant that holds the name of the environment property
  870. * for specifying the DNS host and domain names to use for the
  871. * JNDI URL context (for example, "dns://somehost/wiz.com").
  872. * This property may be specified in the environment,
  873. * an applet parameter, a system property, or a resource file.
  874. * If it is not specified in any of these sources
  875. * and the program attempts to use a JNDI URL containing a DNS name,
  876. * a <tt>ConfigurationException</tt> will be thrown.
  877. *
  878. * <p> The value of this constant is "java.naming.dns.url".
  879. *
  880. * @see #addToEnvironment(String, Object)
  881. * @see #removeFromEnvironment(String)
  882. */
  883. String DNS_URL = "java.naming.dns.url";
  884. /**
  885. * Constant that holds the name of the environment property for
  886. * specifying the authoritativeness of the service requested.
  887. * If the value of the property is the string "true", it means
  888. * that the access is to the most authoritative source (i.e. bypass
  889. * any cache or replicas). If the value is anything else,
  890. * the source need not be (but may be) authoritative.
  891. * If unspecified, the value defaults to "false".
  892. *
  893. * <p> The value of this constant is "java.naming.authoritative".
  894. *
  895. * @see #addToEnvironment(String, Object)
  896. * @see #removeFromEnvironment(String)
  897. */
  898. String AUTHORITATIVE = "java.naming.authoritative";
  899. /**
  900. * Constant that holds the name of the environment property for
  901. * specifying the batch size to use when returning data via the
  902. * service's protocol. This is a hint to the provider to return
  903. * the results of operations in batches of the specified size, so
  904. * the provider can optimize its performance and usage of resources.
  905. * The value of the property is the string representation of an
  906. * integer.
  907. * If unspecified, the batch size is determined by the service
  908. * provider.
  909. *
  910. * <p> The value of this constant is "java.naming.batchsize".
  911. *
  912. * @see #addToEnvironment(String, Object)
  913. * @see #removeFromEnvironment(String)
  914. */
  915. String BATCHSIZE = "java.naming.batchsize";
  916. /**
  917. * Constant that holds the name of the environment property for
  918. * specifying how referrals encountered by the service provider
  919. * are to be processed. The value of the property is one of the
  920. * following strings:
  921. * <dl>
  922. * <dt>"follow"
  923. * <dd>follow referrals automatically
  924. * <dt>"ignore"
  925. * <dd>ignore referrals
  926. * <dt>"throw"
  927. * <dd>throw <tt>ReferralException</tt> when a referral is encountered.
  928. * </dl>
  929. * If this property is not specified, the default is
  930. * determined by the provider.
  931. *
  932. * <p> The value of this constant is "java.naming.referral".
  933. *
  934. * @see #addToEnvironment(String, Object)
  935. * @see #removeFromEnvironment(String)
  936. */
  937. String REFERRAL = "java.naming.referral";
  938. /**
  939. * Constant that holds the name of the environment property for
  940. * specifying the security protocol to use.
  941. * Its value is a string determined by the service provider
  942. * (e.g. "ssl").
  943. * If this property is unspecified,
  944. * the behaviour is determined by the service provider.
  945. *
  946. * <p> The value of this constant is "java.naming.security.protocol".
  947. *
  948. * @see #addToEnvironment(String, Object)
  949. * @see #removeFromEnvironment(String)
  950. */
  951. String SECURITY_PROTOCOL = "java.naming.security.protocol";
  952. /**
  953. * Constant that holds the name of the environment property for
  954. * specifying the security level to use.
  955. * Its value is one of the following strings:
  956. * "none", "simple", "strong".
  957. * If this property is unspecified,
  958. * the behaviour is determined by the service provider.
  959. *
  960. * <p> The value of this constant is "java.naming.security.authentication".
  961. *
  962. * @see #addToEnvironment(String, Object)
  963. * @see #removeFromEnvironment(String)
  964. */
  965. String SECURITY_AUTHENTICATION = "java.naming.security.authentication";
  966. /**
  967. * Constant that holds the name of the environment property for
  968. * specifying the identity of the principal for authenticating
  969. * the caller to the service. The format of the principal
  970. * depends on the authentication scheme.
  971. * If this property is unspecified,
  972. * the behaviour is determined by the service provider.
  973. *
  974. * <p> The value of this constant is "java.naming.security.principal".
  975. *
  976. * @see #addToEnvironment(String, Object)
  977. * @see #removeFromEnvironment(String)
  978. */
  979. String SECURITY_PRINCIPAL = "java.naming.security.principal";
  980. /**
  981. * Constant that holds the name of the environment property for
  982. * specifying the credentials of the principal for authenticating
  983. * the caller to the service. The value of the property depends
  984. * on the authentication scheme. For example, it could be a hashed
  985. * password, clear-text password, key, certificate, and so on.
  986. * If this property is unspecified,
  987. * the behaviour is determined by the service provider.
  988. *
  989. * <p> The value of this constant is "java.naming.security.credentials".
  990. *
  991. * @see #addToEnvironment(String, Object)
  992. * @see #removeFromEnvironment(String)
  993. */
  994. String SECURITY_CREDENTIALS = "java.naming.security.credentials";
  995. /**
  996. * Constant that holds the name of the environment property for
  997. * specifying the preferred language to use with the service.
  998. * The value of the property is a colon-separated list of language
  999. * tags as defined in RFC 1766.
  1000. * If this property is unspecified,
  1001. * the language preference is determined by the service provider.
  1002. *
  1003. * <p> The value of this constant is "java.naming.language".
  1004. *
  1005. * @see #addToEnvironment(String, Object)
  1006. * @see #removeFromEnvironment(String)
  1007. */
  1008. String LANGUAGE = "java.naming.language";
  1009. /**
  1010. * Constant that holds the name of the environment property for
  1011. * specifying an applet for the initial context constructor to use
  1012. * when searching for other properties.
  1013. * The value of this property is the
  1014. * <tt>java.applet.Applet</tt> instance that is being executed.
  1015. * This property may be specified in the environment parameter
  1016. * passed to the initial context constructor.
  1017. * When this property is set, each property that the initial context
  1018. * constructor looks for in the system properties is first looked for
  1019. * in the applet's parameter list.
  1020. * If this property is unspecified, the initial context constructor
  1021. * will search for properties only in the environment parameter
  1022. * passed to it, the system properties, and application resource files.
  1023. *
  1024. * <p> The value of this constant is "java.naming.applet".
  1025. *
  1026. * @see #addToEnvironment(String, Object)
  1027. * @see #removeFromEnvironment(String)
  1028. * @see InitialContext
  1029. *
  1030. * @since 1.3
  1031. */
  1032. String APPLET = "java.naming.applet";
  1033. };