Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/classes/javax/naming/spi/DirObjectFactory.java
38918 views
/*1* Copyright (c) 1999, 2004, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package javax.naming.spi;2627import java.util.Hashtable;28import javax.naming.*;29import javax.naming.directory.Attributes;3031/**32* This interface represents a factory for creating an object given33* an object and attributes about the object.34*<p>35* The JNDI framework allows for object implementations to36* be loaded in dynamically via <em>object factories</em>. See37* <tt>ObjectFactory</tt> for details.38* <p>39* A <tt>DirObjectFactory</tt> extends <tt>ObjectFactory</tt> by allowing40* an <tt>Attributes</tt> instance41* to be supplied to the <tt>getObjectInstance()</tt> method.42* <tt>DirObjectFactory</tt> implementations are intended to be used by <tt>DirContext</tt>43* service providers. The service provider, in addition reading an44* object from the directory, might already have attributes that45* are useful for the object factory to check to see whether the46* factory is supposed to process the object. For instance, an LDAP-style47* service provider might have read the "objectclass" of the object.48* A CORBA object factory might be interested only in LDAP entries49* with "objectclass=corbaObject". By using the attributes supplied by50* the LDAP service provider, the CORBA object factory can quickly51* eliminate objects that it need not worry about, and non-CORBA object52* factories can quickly eliminate CORBA-related LDAP entries.53*54* @author Rosanna Lee55* @author Scott Seligman56*57* @see NamingManager#getObjectInstance58* @see DirectoryManager#getObjectInstance59* @see ObjectFactory60* @since 1.361*/6263public interface DirObjectFactory extends ObjectFactory {64/**65* Creates an object using the location or reference information, and attributes66* specified.67* <p>68* Special requirements of this object are supplied69* using <code>environment</code>.70* An example of such an environment property is user identity71* information.72*<p>73* <tt>DirectoryManager.getObjectInstance()</tt>74* successively loads in object factories. If it encounters a <tt>DirObjectFactory</tt>,75* it will invoke <tt>DirObjectFactory.getObjectInstance()</tt>;76* otherwise, it invokes77* <tt>ObjectFactory.getObjectInstance()</tt>. It does this until a factory78* produces a non-null answer.79* <p> When an exception80* is thrown by an object factory, the exception is passed on to the caller81* of <tt>DirectoryManager.getObjectInstance()</tt>. The search for other factories82* that may produce a non-null answer is halted.83* An object factory should only throw an exception if it is sure that84* it is the only intended factory and that no other object factories85* should be tried.86* If this factory cannot create an object using the arguments supplied,87* it should return null.88*<p>Since <tt>DirObjectFactory</tt> extends <tt>ObjectFactory</tt>, it89* effectively90* has two <tt>getObjectInstance()</tt> methods, where one differs from the other by91* the attributes argument. Given a factory that implements <tt>DirObjectFactory</tt>,92* <tt>DirectoryManager.getObjectInstance()</tt> will only93* use the method that accepts the attributes argument, while94* <tt>NamingManager.getObjectInstance()</tt> will only use the one that does not accept95* the attributes argument.96*<p>97* See <tt>ObjectFactory</tt> for a description URL context factories and other98* properties of object factories that apply equally to <tt>DirObjectFactory</tt>.99*<p>100* The <tt>name</tt>, <tt>attrs</tt>, and <tt>environment</tt> parameters101* are owned by the caller.102* The implementation will not modify these objects or keep references103* to them, although it may keep references to clones or copies.104*105* @param obj The possibly null object containing location or reference106* information that can be used in creating an object.107* @param name The name of this object relative to <code>nameCtx</code>,108* or null if no name is specified.109* @param nameCtx The context relative to which the <code>name</code>110* parameter is specified, or null if <code>name</code> is111* relative to the default initial context.112* @param environment The possibly null environment that is used in113* creating the object.114* @param attrs The possibly null attributes containing some of <tt>obj</tt>'s115* attributes. <tt>attrs</tt> might not necessarily have all of <tt>obj</tt>'s116* attributes. If the object factory requires more attributes, it needs117* to get it, either using <tt>obj</tt>, or <tt>name</tt> and <tt>nameCtx</tt>.118* The factory must not modify attrs.119* @return The object created; null if an object cannot be created.120* @exception Exception If this object factory encountered an exception121* while attempting to create an object, and no other object factories are122* to be tried.123*124* @see DirectoryManager#getObjectInstance125* @see NamingManager#getURLContext126*/127public Object getObjectInstance(Object obj, Name name, Context nameCtx,128Hashtable<?,?> environment,129Attributes attrs)130throws Exception;131}132133134