src/java.naming/share/classes/javax/naming/spi/DirObjectFactory.java
author stefank
Mon, 25 Nov 2019 15:00:32 +0100
changeset 59255 a74627659f96
parent 47216 71c04702a3d5
permissions -rw-r--r--
8234602: ZGC: Windows compile error in ZHeuristic Reviewed-by: pliden, eosterlund
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package javax.naming.spi;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.Hashtable;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import javax.naming.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import javax.naming.directory.Attributes;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
  * This interface represents a factory for creating an object given
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
  * an object and attributes about the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
  *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
  * The JNDI framework allows for object implementations to
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
  * service providers. The service provider, in addition reading an
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
  * object from the directory, might already have attributes that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
  * are useful for the object factory to check to see whether the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
  * factory is supposed to process the object. For instance, an LDAP-style
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
  * service provider might have read the "objectclass" of the object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
  * A CORBA object factory might be interested only in LDAP entries
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
  * with "objectclass=corbaObject". By using the attributes supplied by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
  * the LDAP service provider, the CORBA object factory can quickly
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
  * eliminate objects that it need not worry about, and non-CORBA object
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
  * factories can quickly eliminate CORBA-related LDAP entries.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
  * @author Rosanna Lee
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
  * @author Scott Seligman
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
  *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
  * @see NamingManager#getObjectInstance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
  * @see DirectoryManager#getObjectInstance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
  * @see ObjectFactory
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
  * @since 1.3
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
  */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
public interface DirObjectFactory extends ObjectFactory {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
 * Creates an object using the location or reference information, and attributes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
 * specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 * Special requirements of this object are supplied
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
 * using <code>environment</code>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
 * An example of such an environment property is user identity
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
 * information.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * produces a non-null answer.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 * <p> When an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
 * that may produce a non-null answer is halted.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
 * An object factory should only throw an exception if it is sure that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
 * it is the only intended factory and that no other object factories
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
 * should be tried.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
 * If this factory cannot create an object using the arguments supplied,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
  * the attributes argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
 * are owned by the caller.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
 * The implementation will not modify these objects or keep references
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
 * to them, although it may keep references to clones or copies.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
 * @param obj The possibly null object containing location or reference
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
 *              information that can be used in creating an object.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
 * @param name The name of this object relative to <code>nameCtx</code>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
 *              or null if no name is specified.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
 * @param nameCtx The context relative to which the <code>name</code>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
 *              parameter is specified, or null if <code>name</code> is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
 *              relative to the default initial context.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
 * @param environment The possibly null environment that is used in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   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
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
 *      The factory must not modify attrs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
 * @return The object created; null if an object cannot be created.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
 * @exception Exception If this object factory encountered an exception
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
 * while attempting to create an object, and no other object factories are
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
 * to be tried.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
 * @see DirectoryManager#getObjectInstance
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
 * @see NamingManager#getURLContext
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    public Object getObjectInstance(Object obj, Name name, Context nameCtx,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                                    Hashtable<?,?> environment,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                                    Attributes attrs)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        throws Exception;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
}