author | stefank |
Mon, 25 Nov 2019 15:00:32 +0100 | |
changeset 59255 | a74627659f96 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
5506 | 2 |
* Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
package javax.naming.spi; |
|
27 |
||
28 |
import java.util.Hashtable; |
|
29 |
import javax.naming.*; |
|
30 |
import javax.naming.directory.Attributes; |
|
31 |
||
32 |
/** |
|
33 |
* This interface represents a factory for creating an object given |
|
34 |
* an object and attributes about the object. |
|
35 |
*<p> |
|
36 |
* The JNDI framework allows for object implementations to |
|
37 |
* be loaded in dynamically via <em>object factories</em>. See |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
38 |
* {@code ObjectFactory} for details. |
2 | 39 |
* <p> |
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
40 |
* A {@code DirObjectFactory} extends {@code ObjectFactory} by allowing |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
41 |
* an {@code Attributes} instance |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
42 |
* to be supplied to the {@code getObjectInstance()} method. |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
43 |
* {@code DirObjectFactory} implementations are intended to be used by {@code DirContext} |
2 | 44 |
* service providers. The service provider, in addition reading an |
45 |
* object from the directory, might already have attributes that |
|
46 |
* are useful for the object factory to check to see whether the |
|
47 |
* factory is supposed to process the object. For instance, an LDAP-style |
|
48 |
* service provider might have read the "objectclass" of the object. |
|
49 |
* A CORBA object factory might be interested only in LDAP entries |
|
50 |
* with "objectclass=corbaObject". By using the attributes supplied by |
|
51 |
* the LDAP service provider, the CORBA object factory can quickly |
|
52 |
* eliminate objects that it need not worry about, and non-CORBA object |
|
53 |
* factories can quickly eliminate CORBA-related LDAP entries. |
|
54 |
* |
|
55 |
* @author Rosanna Lee |
|
56 |
* @author Scott Seligman |
|
57 |
* |
|
58 |
* @see NamingManager#getObjectInstance |
|
59 |
* @see DirectoryManager#getObjectInstance |
|
60 |
* @see ObjectFactory |
|
61 |
* @since 1.3 |
|
62 |
*/ |
|
63 |
||
64 |
public interface DirObjectFactory extends ObjectFactory { |
|
65 |
/** |
|
66 |
* Creates an object using the location or reference information, and attributes |
|
67 |
* specified. |
|
68 |
* <p> |
|
69 |
* Special requirements of this object are supplied |
|
70 |
* using <code>environment</code>. |
|
71 |
* An example of such an environment property is user identity |
|
72 |
* information. |
|
73 |
*<p> |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
74 |
* {@code DirectoryManager.getObjectInstance()} |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
75 |
* successively loads in object factories. If it encounters a {@code DirObjectFactory}, |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
76 |
* it will invoke {@code DirObjectFactory.getObjectInstance()}; |
2 | 77 |
* otherwise, it invokes |
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
78 |
* {@code ObjectFactory.getObjectInstance()}. It does this until a factory |
2 | 79 |
* produces a non-null answer. |
80 |
* <p> When an exception |
|
81 |
* is thrown by an object factory, the exception is passed on to the caller |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
82 |
* of {@code DirectoryManager.getObjectInstance()}. The search for other factories |
2 | 83 |
* that may produce a non-null answer is halted. |
84 |
* An object factory should only throw an exception if it is sure that |
|
85 |
* it is the only intended factory and that no other object factories |
|
86 |
* should be tried. |
|
87 |
* If this factory cannot create an object using the arguments supplied, |
|
88 |
* it should return null. |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
89 |
*<p>Since {@code DirObjectFactory} extends {@code ObjectFactory}, it |
2 | 90 |
* effectively |
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
91 |
* has two {@code getObjectInstance()} methods, where one differs from the other by |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
92 |
* the attributes argument. Given a factory that implements {@code DirObjectFactory}, |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
93 |
* {@code DirectoryManager.getObjectInstance()} will only |
2 | 94 |
* use the method that accepts the attributes argument, while |
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
95 |
* {@code NamingManager.getObjectInstance()} will only use the one that does not accept |
2 | 96 |
* the attributes argument. |
97 |
*<p> |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
98 |
* See {@code ObjectFactory} for a description URL context factories and other |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
99 |
* properties of object factories that apply equally to {@code DirObjectFactory}. |
2 | 100 |
*<p> |
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
101 |
* The {@code name}, {@code attrs}, and {@code environment} parameters |
2 | 102 |
* are owned by the caller. |
103 |
* The implementation will not modify these objects or keep references |
|
104 |
* to them, although it may keep references to clones or copies. |
|
105 |
* |
|
106 |
* @param obj The possibly null object containing location or reference |
|
107 |
* information that can be used in creating an object. |
|
108 |
* @param name The name of this object relative to <code>nameCtx</code>, |
|
109 |
* or null if no name is specified. |
|
110 |
* @param nameCtx The context relative to which the <code>name</code> |
|
111 |
* parameter is specified, or null if <code>name</code> is |
|
112 |
* relative to the default initial context. |
|
113 |
* @param environment The possibly null environment that is used in |
|
114 |
* creating the object. |
|
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
115 |
* @param attrs The possibly null attributes containing some of {@code obj}'s |
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
116 |
* attributes. {@code attrs} might not necessarily have all of {@code obj}'s |
2 | 117 |
* attributes. If the object factory requires more attributes, it needs |
32029
a5538163e144
8132877: docs: replace <tt> tags (obsolete in html5) for javax.naming
avstepan
parents:
25859
diff
changeset
|
118 |
* to get it, either using {@code obj}, or {@code name} and {@code nameCtx}. |
2 | 119 |
* The factory must not modify attrs. |
120 |
* @return The object created; null if an object cannot be created. |
|
121 |
* @exception Exception If this object factory encountered an exception |
|
122 |
* while attempting to create an object, and no other object factories are |
|
123 |
* to be tried. |
|
124 |
* |
|
125 |
* @see DirectoryManager#getObjectInstance |
|
126 |
* @see NamingManager#getURLContext |
|
127 |
*/ |
|
128 |
public Object getObjectInstance(Object obj, Name name, Context nameCtx, |
|
129 |
Hashtable<?,?> environment, |
|
130 |
Attributes attrs) |
|
131 |
throws Exception; |
|
132 |
} |