1. /*
  2. * @(#)ObjectFactoryBuilder.java 1.10 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. package javax.naming.spi;
  8. import java.util.Hashtable;
  9. import javax.naming.NamingException;
  10. /**
  11. * This interface represents a builder that creates object factories.
  12. *<p>
  13. * The JNDI framework allows for object implementations to
  14. * be loaded in dynamically via <em>object factories</em>.
  15. * For example, when looking up a printer bound in the name space,
  16. * if the print service binds printer names to References, the printer
  17. * Reference could be used to create a printer object, so that
  18. * the caller of lookup can directly operate on the printer object
  19. * after the lookup. An ObjectFactory is responsible for creating
  20. * objects of a specific type. JNDI uses a default policy for using
  21. * and loading object factories. You can override this default policy
  22. * by calling <tt>NamingManager.setObjectFactoryBuilder()</tt> with an ObjectFactoryBuilder,
  23. * which contains the program-defined way of creating/loading
  24. * object factories.
  25. * Any <tt>ObjectFactoryBuilder</tt> implementation must implement this
  26. * interface that for creating object factories.
  27. *
  28. * @author Rosanna Lee
  29. * @author Scott Seligman
  30. * @version 1.10 04/07/16
  31. *
  32. * @see ObjectFactory
  33. * @see NamingManager#getObjectInstance
  34. * @see NamingManager#setObjectFactoryBuilder
  35. * @since 1.3
  36. */
  37. public interface ObjectFactoryBuilder {
  38. /**
  39. * Creates a new object factory using the environment supplied.
  40. *<p>
  41. * The environment parameter is owned by the caller.
  42. * The implementation will not modify the object or keep a reference
  43. * to it, although it may keep a reference to a clone or copy.
  44. *
  45. * @param obj The possibly null object for which to create a factory.
  46. * @param environment Environment to use when creating the factory.
  47. * Can be null.
  48. * @return A non-null new instance of an ObjectFactory.
  49. * @exception NamingException If an object factory cannot be created.
  50. *
  51. */
  52. public ObjectFactory createObjectFactory(Object obj,
  53. Hashtable<?,?> environment)
  54. throws NamingException;
  55. }