KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > javax > naming > spi > DirObjectFactory


1 /*
2  * @(#)DirObjectFactory.java 1.11 04/07/16
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8 package javax.naming.spi;
9
10 import java.util.Hashtable JavaDoc;
11 import javax.naming.*;
12 import javax.naming.directory.Attributes JavaDoc;
13
14 /**
15   * This interface represents a factory for creating an object given
16   * an object and attributes about the object.
17   *<p>
18   * The JNDI framework allows for object implementations to
19   * be loaded in dynamically via <em>object factories</em>. See
20   * <tt>ObjectFactory</tt> for details.
21   * <p>
22   * A <tt>DirObjectFactory</tt> extends <tt>ObjectFactory</tt> by allowing
23   * an <tt>Attributes</tt> instance
24   * to be supplied to the <tt>getObjectInstance()</tt> method.
25   * <tt>DirObjectFactory</tt> implementations are intended to be used by <tt>DirContext</tt>
26   * service providers. The service provider, in addition reading an
27   * object from the directory, might already have attributes that
28   * are useful for the object factory to check to see whether the
29   * factory is supposed to process the object. For instance, an LDAP-style
30   * service provider might have read the "objectclass" of the object.
31   * A CORBA object factory might be interested only in LDAP entries
32   * with "objectclass=corbaObject". By using the attributes supplied by
33   * the LDAP service provider, the CORBA object factory can quickly
34   * eliminate objects that it need not worry about, and non-CORBA object
35   * factories can quickly eliminate CORBA-related LDAP entries.
36   *
37   * @author Rosanna Lee
38   * @author Scott Seligman
39   * @version 1.11 04/07/16
40   *
41   * @see NamingManager#getObjectInstance
42   * @see DirectoryManager#getObjectInstance
43   * @see ObjectFactory
44   * @since 1.3
45   */

46
47 public interface DirObjectFactory extends ObjectFactory JavaDoc {
48 /**
49  * Creates an object using the location or reference information, and attributes
50  * specified.
51  * <p>
52  * Special requirements of this object are supplied
53  * using <code>environment</code>.
54  * An example of such an environment property is user identity
55  * information.
56  *<p>
57  * <tt>DirectoryManager.getObjectInstance()</tt>
58  * successively loads in object factories. If it encounters a <tt>DirObjectFactory</tt>,
59  * it will invoke <tt>DirObjectFactory.getObjectInstance()</tt>;
60  * otherwise, it invokes
61  * <tt>ObjectFactory.getObjectInstance()</tt>. It does this until a factory
62  * produces a non-null answer.
63  * <p> When an exception
64  * is thrown by an object factory, the exception is passed on to the caller
65  * of <tt>DirectoryManager.getObjectInstance()</tt>. The search for other factories
66  * that may produce a non-null answer is halted.
67  * An object factory should only throw an exception if it is sure that
68  * it is the only intended factory and that no other object factories
69  * should be tried.
70  * If this factory cannot create an object using the arguments supplied,
71  * it should return null.
72   *<p>Since <tt>DirObjectFactory</tt> extends <tt>ObjectFactory</tt>, it
73   * effectively
74   * has two <tt>getObjectInstance()</tt> methods, where one differs from the other by
75   * the attributes argument. Given a factory that implements <tt>DirObjectFactory</tt>,
76   * <tt>DirectoryManager.getObjectInstance()</tt> will only
77   * use the method that accepts the attributes argument, while
78   * <tt>NamingManager.getObjectInstance()</tt> will only use the one that does not accept
79   * the attributes argument.
80  *<p>
81  * See <tt>ObjectFactory</tt> for a description URL context factories and other
82  * properties of object factories that apply equally to <tt>DirObjectFactory</tt>.
83  *<p>
84  * The <tt>name</tt>, <tt>attrs</tt>, and <tt>environment</tt> parameters
85  * are owned by the caller.
86  * The implementation will not modify these objects or keep references
87  * to them, although it may keep references to clones or copies.
88  *
89  * @param obj The possibly null object containing location or reference
90  * information that can be used in creating an object.
91  * @param name The name of this object relative to <code>nameCtx</code>,
92  * or null if no name is specified.
93  * @param nameCtx The context relative to which the <code>name</code>
94  * parameter is specified, or null if <code>name</code> is
95  * relative to the default initial context.
96  * @param environment The possibly null environment that is used in
97  * creating the object.
98  * @param attrs The possibly null attributes containing some of <tt>obj</tt>'s
99  * attributes. <tt>attrs</tt> might not necessarily have all of <tt>obj</tt>'s
100  * attributes. If the object factory requires more attributes, it needs
101  * to get it, either using <tt>obj</tt>, or <tt>name</tt> and <tt>nameCtx</tt>.
102  * The factory must not modify attrs.
103  * @return The object created; null if an object cannot be created.
104  * @exception Exception If this object factory encountered an exception
105  * while attempting to create an object, and no other object factories are
106  * to be tried.
107  *
108  * @see DirectoryManager#getObjectInstance
109  * @see NamingManager#getURLContext
110  */

111     public Object JavaDoc getObjectInstance(Object JavaDoc obj, Name name, Context nameCtx,
112                     Hashtable JavaDoc<?,?> environment,
113                     Attributes JavaDoc attrs)
114     throws Exception JavaDoc;
115 }
116
Popular Tags