The JNDI framework allows for object implementations to
be loaded in dynamically via object factories.
A DirStateFactory extends StateFactory
by allowing an Attributes instance
to be supplied to and be returned by the getStateToBind() method.
DirStateFactory implementations are intended to be used by
DirContext service providers.
When a caller binds an object using DirContext.bind(),
he might also specify a set of attributes to be bound with the object.
The object and attributes to be bound are passed to
the getStateToBind() method of a factory.
If the factory processes the object and attributes, it returns
a corresponding pair of object and attributes to be bound.
If the factory does not process the object, it must return null.
For example, a caller might bind a printer object with some printer-related attributes.
ctx.rebind("inky", printer, printerAttrs);
An LDAP service provider for ctx uses a DirStateFactory
(indirectly via DirectoryManager.getStateToBind())
and gives it printer and printerAttrs. A factory for
an LDAP directory might turn printer into a set of attributes
and merge that with printerAttrs. The service provider then
uses the resulting attributes to create an LDAP entry and updates
the directory.
Since DirStateFactory extends StateFactory, it
has two getStateToBind() methods, where one
differs from the other by the attributes
argument. DirectoryManager.getStateToBind() will only use
the form that accepts the attributes argument, while
NamingManager.getStateToBind() will only use the form that
does not accept the attributes argument.
Either form of the getStateToBind() method of a
DirStateFactory may be invoked multiple times, possibly using different
parameters. The implementation is thread-safe.
DirectoryManager#getStateToBind, DirObjectFactory
| Modifier and Type | Class and Description |
|---|---|
| public static class | DirStateFactory.
An object/attributes pair for returning the result of DirStateFactory.getStateToBind(). |
| Modifier and Type | Method and Description |
|---|---|
| public DirStateFactory. | Returns: AResult containing the object's state for binding
and the corresponding
attributes to be bound; null if the object don't use this factory.A possibly null object whose state is to be retrieved. 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 to
be used in the creation of the object's state. environment, Attributes The possibly null attributes to be bound with the object.
The factory must not modify inAttrs)inAttrs.Retrieves the state of an object for binding given the object and attributes to be transformed. |
| getStateToBind | back to summary |
|---|---|
| public DirStateFactory. Retrieves the state of an object for binding given the object and attributes to be transformed.
When an exception is thrown by a factory,
the exception is passed on to the caller
of
The
The
| |
| Modifier and Type | Field and Description |
|---|---|
| private Attributes | attrs
The possibly null attributes to be bound. |
| private Object | obj
The possibly null object to be bound. |
| Access | Constructor and Description |
|---|---|
| public | Result(Object
The possibly null object to be bound. obj, Attributes The possibly null attributes to be bound. outAttrs)Constructs an instance of Result. |
| Modifier and Type | Method and Description |
|---|---|
| public Attributes | Returns: The possibly null attributes to be bound.Retrieves the attributes to be bound. |
| public Object |
| attrs | back to summary |
|---|---|
| private Attributes attrs The possibly null attributes to be bound. | |
| obj | back to summary |
|---|---|
| private Object obj The possibly null object to be bound. | |
| Result | back to summary |
|---|---|
| public Result(Object obj, Attributes outAttrs) Constructs an instance of Result.
| |
| getAttributes | back to summary |
|---|---|
| public Attributes getAttributes() Retrieves the attributes to be bound.
| |
| getObject | back to summary |
|---|---|
| public Object getObject() Retrieves the object to be bound.
| |