Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/src/java.naming/share/classes/javax/naming/spi/DirObjectFactory.java
41159 views
1
/*
2
* Copyright (c) 1999, 2020, Oracle and/or its affiliates. All rights reserved.
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
7
* published by the Free Software Foundation. Oracle designates this
8
* particular file as subject to the "Classpath" exception as provided
9
* by Oracle in the LICENSE file that accompanied this code.
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
*
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.
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
38
* {@code ObjectFactory} for details.
39
* <p>
40
* A {@code DirObjectFactory} extends {@code ObjectFactory} by allowing
41
* an {@code Attributes} instance
42
* to be supplied to the {@code getObjectInstance()} method.
43
* {@code DirObjectFactory} implementations are intended to be used by {@code DirContext}
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>
74
* {@code DirectoryManager.getObjectInstance()}
75
* successively loads in object factories. If it encounters a {@code DirObjectFactory},
76
* it will invoke {@code DirObjectFactory.getObjectInstance()};
77
* otherwise, it invokes
78
* {@code ObjectFactory.getObjectInstance()}. It does this until a factory
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
82
* of {@code DirectoryManager.getObjectInstance()}. The search for other factories
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.
89
*<p>Since {@code DirObjectFactory} extends {@code ObjectFactory}, it
90
* effectively
91
* has two {@code getObjectInstance()} methods, where one differs from the other by
92
* the attributes argument. Given a factory that implements {@code DirObjectFactory},
93
* {@code DirectoryManager.getObjectInstance()} will only
94
* use the method that accepts the attributes argument, while
95
* {@code NamingManager.getObjectInstance()} will only use the one that does not accept
96
* the attributes argument.
97
*<p>
98
* See {@code ObjectFactory} for a description URL context factories and other
99
* properties of object factories that apply equally to {@code DirObjectFactory}.
100
*<p>
101
* The {@code name}, {@code attrs}, and {@code environment} parameters
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.
115
* @param attrs The possibly null attributes containing some of {@code obj}'s
116
* attributes. {@code attrs} might not necessarily have all of {@code obj}'s
117
* attributes. If the object factory requires more attributes, it needs
118
* to get it, either using {@code obj}, or {@code name} and {@code nameCtx}.
119
* The factory must not modify attrs.
120
* @return The object created; null if an object cannot be created.
121
* @throws 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
}
133
134