The JNDI framework allows for object implementations to be loaded in dynamically via object factories. For example, when looking up a printer bound in the name space, if the print service binds printer names to References, the printer Reference could be used to create a printer object, so that the caller of lookup can directly operate on the printer object after the lookup.
An ObjectFactory
is responsible
for creating objects of a specific type. In the above example,
you may have a PrinterObjectFactory for creating Printer objects.
An object factory must implement the ObjectFactory
interface.
In addition, the factory class must be public and must have a
public constructor that accepts no parameters.
Note that in cases where the factory is in a named module then it must be
in a package which is exported by that module to the java.naming
module.
The getObjectInstance()
method of an object factory may
be invoked multiple times, possibly using different parameters.
The implementation is thread-safe.
The mention of URL in the documentation for this class refers to a URL string as defined by RFC 1738 and its related RFCs. It is any string that conforms to the syntax described therein, and may not always have corresponding support in the java.net.URL class or Web browsers.
NamingManager#getObjectInstance
, NamingManager#getURLContext
, ObjectFactoryBuilder
, StateFactory
Modifier and Type | Method and Description |
---|---|
public Object | Returns: The object created; null if an object cannot be created.The possibly null object containing location or reference
information that can be used in creating an object. obj, Name The name of this object relative to name, Context nameCtx ,
or null if no name is specified.The context relative to which the nameCtx, Hashtable<?, ?> name
parameter is specified, or null if name is
relative to the default initial context.The possibly null environment that is used in
creating the object. environment)Creates an object using the location or reference information specified. |
getObjectInstance | back to summary |
---|---|
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable<?, ?> environment) throws Exception Creates an object using the location or reference information specified.
Special requirements of this object are supplied
using
A URL context factory is a special ObjectFactory that
creates contexts for resolving URLs or objects whose locations
are specified by URLs. The
The
Name and Context Parameters.
The
|