1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> |
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> |
2 <html> |
2 <html> |
3 <head> |
3 <head> |
4 <!-- |
4 <!-- |
5 Copyright (c) 1999, 2006, Oracle and/or its affiliates. All rights reserved. |
5 Copyright (c) 1999, 2019, Oracle and/or its affiliates. All rights reserved. |
6 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
6 DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
7 |
7 |
8 This code is free software; you can redistribute it and/or modify it |
8 This code is free software; you can redistribute it and/or modify it |
9 under the terms of the GNU General Public License version 2 only, as |
9 under the terms of the GNU General Public License version 2 only, as |
10 published by the Free Software Foundation. Oracle designates this |
10 published by the Free Software Foundation. Oracle designates this |
38 independent of any specific naming or directory service |
38 independent of any specific naming or directory service |
39 implementation. Thus a variety of services--new, emerging, and |
39 implementation. Thus a variety of services--new, emerging, and |
40 already deployed ones--can be accessed in a common way. |
40 already deployed ones--can be accessed in a common way. |
41 |
41 |
42 |
42 |
43 <h3>Context</h3> |
43 <h2>Context</h2> |
44 <p> |
44 <p> |
45 This package defines the notion of a <em>context</em>, represented |
45 This package defines the notion of a <em>context</em>, represented |
46 by the <code>Context</code> interface. |
46 by the <code>Context</code> interface. |
47 A context consists of a set of name-to-object <em>bindings</em>. |
47 A context consists of a set of name-to-object <em>bindings</em>. |
48 <code>Context</code> is the core interface for looking up, binding, unbinding, |
48 <code>Context</code> is the core interface for looking up, binding, unbinding, |
61 Printer printer = (Printer)ctx.lookup("treekiller"); |
61 Printer printer = (Printer)ctx.lookup("treekiller"); |
62 printer.print(report); |
62 printer.print(report); |
63 </pre> |
63 </pre> |
64 </blockquote> |
64 </blockquote> |
65 |
65 |
66 <h3>Names</h3> |
66 <h2>Names</h2> |
67 <p> |
67 <p> |
68 Every naming method in the <code>Context</code> |
68 Every naming method in the <code>Context</code> |
69 interface has two |
69 interface has two |
70 overloads: one that accepts a |
70 overloads: one that accepts a |
71 <code>Name</code> argument and one that accepts a string name. |
71 <code>Name</code> argument and one that accepts a string name. |
80 them, comparing components, and so on. |
80 them, comparing components, and so on. |
81 The overloads that accept string names are likely to be more useful |
81 The overloads that accept string names are likely to be more useful |
82 for simple applications, such as those that simply read in a name |
82 for simple applications, such as those that simply read in a name |
83 and look up the corresponding object. |
83 and look up the corresponding object. |
84 |
84 |
85 <h3>Bindings</h3> |
85 <h2>Bindings</h2> |
86 |
86 |
87 The <code>Binding</code> class represents a name-to-object binding. |
87 The <code>Binding</code> class represents a name-to-object binding. |
88 It is a tuple containing the name of the bound object, |
88 It is a tuple containing the name of the bound object, |
89 the name of the object's class, and the object itself. |
89 the name of the object's class, and the object itself. |
90 <p> |
90 <p> |
93 simply of the object's name and the object's class name. |
93 simply of the object's name and the object's class name. |
94 The <code>NameClassPair</code> is useful when you only want |
94 The <code>NameClassPair</code> is useful when you only want |
95 information about the object's class and do not want to |
95 information about the object's class and do not want to |
96 pay the extra cost of getting the object. |
96 pay the extra cost of getting the object. |
97 |
97 |
98 <h3>References</h3> |
98 <h2>References</h2> |
99 Objects are stored in naming and directory services in different ways. |
99 Objects are stored in naming and directory services in different ways. |
100 If an object store supports storing Java objects, |
100 If an object store supports storing Java objects, |
101 it might support storing an object in its serialized form. |
101 it might support storing an object in its serialized form. |
102 However, some naming and directory services do not support the |
102 However, some naming and directory services do not support the |
103 storing of Java objects. Furthermore, for some |
103 storing of Java objects. Furthermore, for some |
110 into the Java objects they represent, so that |
110 into the Java objects they represent, so that |
111 JNDI clients have the illusion that what |
111 JNDI clients have the illusion that what |
112 is stored in the directory are Java objects. |
112 is stored in the directory are Java objects. |
113 |
113 |
114 |
114 |
115 <h3>The Initial Context</h3> |
115 <h2>The Initial Context</h2> |
116 |
116 |
117 In JNDI, all naming and directory operations are performed relative |
117 In JNDI, all naming and directory operations are performed relative |
118 to a context. There are no absolute roots. |
118 to a context. There are no absolute roots. |
119 Therefore JNDI defines an <em>initial context</em>, |
119 Therefore JNDI defines an <em>initial context</em>, |
120 <code>InitialContext</code>, |
120 <code>InitialContext</code>, |
121 which provides a starting point for naming and directory operations. |
121 which provides a starting point for naming and directory operations. |
122 Once you have an initial context, you can use it to |
122 Once you have an initial context, you can use it to |
123 look up other contexts and objects. |
123 look up other contexts and objects. |
124 |
124 |
125 <h3>Exceptions</h3> |
125 <h2>Exceptions</h2> |
126 |
126 |
127 JNDI defines a class hierarchy for exceptions that can be thrown in |
127 JNDI defines a class hierarchy for exceptions that can be thrown in |
128 the course of performing naming and directory operations. The root of |
128 the course of performing naming and directory operations. The root of |
129 this class hierarchy is <code>NamingException</code>. |
129 this class hierarchy is <code>NamingException</code>. |
130 Programs interested in dealing with a particular exception |
130 Programs interested in dealing with a particular exception |