|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
This interface represents a factory for obtaining the state of an object for storing.
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.
For the reverse process, when an object is stored into the namespace, JNDi provides "object state factories." Continuing with the printer example, suppose the printer object is updated and rebound:
The service provider for ctx uses an object state factory to obtain the state of printer for storing into its namespace. An LDAP object state factory might turn the printer object into a set of attributes to be stored into an LDAP directories.ctx.rebind("inky", printer);
Each object state factory must export the ObjectStateFactory interface. In addition, the factory class must be public and must have a public constructor that accepts no arguments.
NamingManager#getStateToStore
,
ObjectFactory
Method Summary | |
java.lang.Object |
getStateToStore(java.lang.Object obj,
Name name,
Context nameCtx,
java.util.Hashtable environment)
Retrieves the state of an object for storing. |
Method Detail |
public java.lang.Object getStateToStore(java.lang.Object obj, Name name, Context nameCtx, java.util.Hashtable environment) throws java.lang.Exception
If the factory requires the object's environment, it should use nameCtx.getEnvironment().
NamingManager.getStateToStore() successively loads in object state factories and invokes this method on them until one produces a non-null answer. When an exception is thrown by a factory, the exception is passed on to the caller of NamingManager.getStateToStore(). The search for other factories that may produce a non-null answer is halted. A factory should only throw an exception if it is sure that it is the only intended factory and that no other factories should be tried. If this factory cannot create an object using the arguments supplied, it should return null.
The name
and nameCtx
parameters may
optionally be used to specify the name of the object being created.
name
is the name of the object, relative to context
nameCtx
.
If there are several possible contexts from which the object
could be named -- as will often be the case -- it is up to
the caller to select one. A good rule of thumb is to select the
"deepest" context available.
If nameCtx
is null, name
is relative
to the default initial context. If no name is being specified, the
name
parameter should be null.
obj
- A non-null object whose state is to be retrieved.name
- The name of this object relative to nameCtx
.
Specifying a name is optional; if it is
omitted, name
should be null.nameCtx
- The context relative to which the name
parameter is specified. If null, name
is
relative to the default initial context.environment
- The possibly null environment to
be used in the creation of the object's state.NamingManager#getStateToStore
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |