| javax.naming.spi.StateFactory
StateFactory | public interface StateFactory (Code) | | The StateFactory interface describes a factory used to get the
state of an object to be bound. Using a lookup() on a suitable
context, an class may be found representing, say, a printer; an
ObjectFactory may be used to create an instance of the printer
object class and methods defined by the printer class may be used to inspect
and manipulate the printer. There is a reverse mechanism in which a
StateFactory is used by the service provider to obtain the
state of the (in this case) printer for storing in the naming system. In
addition to implementing this interface, a StateFactory class
must be public and have a public constructor taking no parameters.
Note that while StateFactory is meant to be used in
Context service providers, whereas
DirStateFactory is meant to be used in DirContext
service providers.
|
getStateToBind | Object getStateToBind(Object o, Name n, Context c, Hashtable, ?> envmt) throws NamingException(Code) | | Returns a new instance of the specified object o
containing the state of the object to be bound, customized by the
specified envmt parameter. The name and context parameters
optionally specify the name of the object being created.
Object and state factories are specified via environment properties from
several sources including provider properties files (see the
specification of the Context interface) and may comprise a
list of factories. When the service provider looks to obtain the list of
state factories, the environment and provider properties files are search
for the property name specified by constant
Context.STATE_FACTORIES . Each state factory in the
resulting list is used by NamingManager.getStateToBind()
which invokes this method on each of them until a non-null result is
achieved or until the list is exhausted. If a StateFactory
throws an exception, it should be passed back to the code that invoked
NamingManager.getStateToBind() and no further state
factories in the list are examined. An exception should only be thrown by
a state factory if it is intended that no other state factories be
examined. Usually, if an state factory is unable to return the state of
an object, then null should be returned.
Parameters: o - may be null, or specifies the returning instance Parameters: n - may be null, or specifies the name relative to the specifiedcontext c . The implementation may clone orcopy this object, but will not modify the original. Parameters: c - the context to which the name parameter is relative, or may benull when using a name relative the the default initialcontext. If a factory uses this context object,synchronization should be used as context objects are notthread-safe. Parameters: envmt - may be null; the implementation may clone or copy this object,but will not modify the original. either a new instance of the specified object o containing the state of the object to be bound, customized by thespecified envmt parameter. Or null if no objectcould be created. throws: NamingException - if it is intended that no other state factories be examined. |
|
|