| State Factories

## Examples

> Here are some examples of how state factories are used in the examples from this lesson and the Storing Objects in the Directory lesson.

> - Reference example . `Fruit` is a `Referenceable` object. The service provider extracts its reference by using `Referenceable.getReference()` and stores the reference into the directory. No state factory is used.
> - Attributes example . `Drink` is a `DirContext` object. The service provider extracts its attributes by using `DirContext.getAttributes()` and stores the attributes into the directory. No state factory is used.
> - Serialization example . No state factory is used. The service provider serializes the `java.awt.Button` object and stores its serialized form into the directory.
> - Remote reference example . The service provider stores the `Reference` in the directory. No state factory is used.
> - Remote (JRMP) object example . A state factory (bundled with the service provider) turns the `java.rmi.Remote` object into a marshalled object, which is then stored by the service provider into the directory.
> - Remote (IIOP) object example . A state factory (bundled with the service provider) turns the `java.rmi.Remote` object into a stringified CORBA object reference, which is then stored by the service provider into the directory.
> - CORBA example . A state factory (bundled with the service provider) turns the CORBA object into a stringified CORBA object reference, which is then stored by the service provider in the directory.
> - Custom object example . The state factory `PersonStateFactory` turns a `Person` object into a set of attributes, which is then stored by the service provider into the directory. `PersonStateFactory` is identified in the application resource file used by the client program (`CustomObj`).

> The remainder of this section describes the state factory `PersonStateFactory`.

| State Factories