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 * <tt>ObjectFactory</tt> for details. 39 * <p> 40 * A <tt>DirObjectFactory</tt> extends <tt>ObjectFactory</tt> by allowing 41 * an <tt>Attributes</tt> instance 42 * to be supplied to the <tt>getObjectInstance()</tt> method. 43 * <tt>DirObjectFactory</tt> implementations are intended to be used by <tt>DirContext</tt> 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 * <tt>DirectoryManager.getObjectInstance()</tt> 75 * successively loads in object factories. If it encounters a <tt>DirObjectFactory</tt>, 76 * it will invoke <tt>DirObjectFactory.getObjectInstance()</tt>; 77 * otherwise, it invokes 78 * <tt>ObjectFactory.getObjectInstance()</tt>. 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 <tt>DirectoryManager.getObjectInstance()</tt>. 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 <tt>DirObjectFactory</tt> extends <tt>ObjectFactory</tt>, it 90 * effectively 91 * has two <tt>getObjectInstance()</tt> methods, where one differs from the other by 92 * the attributes argument. Given a factory that implements <tt>DirObjectFactory</tt>, 93 * <tt>DirectoryManager.getObjectInstance()</tt> will only 94 * use the method that accepts the attributes argument, while 95 * <tt>NamingManager.getObjectInstance()</tt> will only use the one that does not accept 96 * the attributes argument. 97 *<p> 98 * See <tt>ObjectFactory</tt> for a description URL context factories and other 99 * properties of object factories that apply equally to <tt>DirObjectFactory</tt>. 100 *<p> 101 * The <tt>name</tt>, <tt>attrs</tt>, and <tt>environment</tt> 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 <tt>obj</tt>'s 116 * attributes. <tt>attrs</tt> might not necessarily have all of <tt>obj</tt>'s 117 * attributes. If the object factory requires more attributes, it needs 118 * to get it, either using <tt>obj</tt>, or <tt>name</tt> and <tt>nameCtx</tt>. 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 } | 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 * @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 } |