Path: blob/master/src/java.naming/share/classes/javax/naming/spi/ObjectFactoryBuilder.java
41159 views
/*1* Copyright (c) 1999, 2020, 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.NamingException;2930/**31* This interface represents a builder that creates object factories.32*<p>33* The JNDI framework allows for object implementations to34* be loaded in dynamically via <em>object factories</em>.35* For example, when looking up a printer bound in the name space,36* if the print service binds printer names to References, the printer37* Reference could be used to create a printer object, so that38* the caller of lookup can directly operate on the printer object39* after the lookup. An ObjectFactory is responsible for creating40* objects of a specific type. JNDI uses a default policy for using41* and loading object factories. You can override this default policy42* by calling {@code NamingManager.setObjectFactoryBuilder()} with an ObjectFactoryBuilder,43* which contains the program-defined way of creating/loading44* object factories.45* Any {@code ObjectFactoryBuilder} implementation must implement this46* interface that for creating object factories.47*48* @author Rosanna Lee49* @author Scott Seligman50*51* @see ObjectFactory52* @see NamingManager#getObjectInstance53* @see NamingManager#setObjectFactoryBuilder54* @since 1.355*/56public interface ObjectFactoryBuilder {57/**58* Creates a new object factory using the environment supplied.59*<p>60* The environment parameter is owned by the caller.61* The implementation will not modify the object or keep a reference62* to it, although it may keep a reference to a clone or copy.63*64* @param obj The possibly null object for which to create a factory.65* @param environment Environment to use when creating the factory.66* Can be null.67* @return A non-null new instance of an ObjectFactory.68* @throws NamingException If an object factory cannot be created.69*70*/71public ObjectFactory createObjectFactory(Object obj,72Hashtable<?,?> environment)73throws NamingException;74}757677