jdk/src/share/classes/javax/naming/spi/DirObjectFactory.java
author duke
Sat, 01 Dec 2007 00:00:00 +0000
changeset 2 90ce3da70b43
child 5506 202f599c92aa
permissions -rw-r--r--
Initial load
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
     2
 * Copyright 1999-2004 Sun Microsystems, Inc.  All Rights Reserved.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
  * <tt>ObjectFactory</tt> for details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
  * <p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
  * A <tt>DirObjectFactory</tt> extends <tt>ObjectFactory</tt> by allowing
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
  * an <tt>Attributes</tt> instance
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
  * to be supplied to the <tt>getObjectInstance()</tt> method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
  * <tt>DirObjectFactory</tt> implementations are intended to be used by <tt>DirContext</tt>
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>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
 * <tt>DirectoryManager.getObjectInstance()</tt>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
 * successively loads in object factories. If it encounters a <tt>DirObjectFactory</tt>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
 * it will invoke <tt>DirObjectFactory.getObjectInstance()</tt>;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
 * otherwise, it invokes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
 * <tt>ObjectFactory.getObjectInstance()</tt>. It does this until a factory
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
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
 * of <tt>DirectoryManager.getObjectInstance()</tt>. The search for other factories
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
  *<p>Since <tt>DirObjectFactory</tt> extends <tt>ObjectFactory</tt>, it
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
  * effectively
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
  * has two <tt>getObjectInstance()</tt> methods, where one differs from the other by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
  * the attributes argument. Given a factory that implements <tt>DirObjectFactory</tt>,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
  * <tt>DirectoryManager.getObjectInstance()</tt> will only
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
  * use the method that accepts the attributes argument, while
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
  * <tt>NamingManager.getObjectInstance()</tt> will only use the one that does not accept
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
  * the attributes argument.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
 *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
 * See <tt>ObjectFactory</tt> for a description URL context factories and other
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
 * properties of object factories that apply equally to <tt>DirObjectFactory</tt>.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
 *<p>
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
 * The <tt>name</tt>, <tt>attrs</tt>, and <tt>environment</tt> parameters
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.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
 * @param attrs The possibly null attributes containing some of <tt>obj</tt>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
 * attributes. <tt>attrs</tt> might not necessarily have all of <tt>obj</tt>'s
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
 * attributes. If the object factory requires more attributes, it needs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
 * to get it, either using <tt>obj</tt>, or <tt>name</tt> and <tt>nameCtx</tt>.
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
}