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