Serialization using Java

[Java programming language only]Java serialization refers to either default serialization, which uses the Serializable interface, or custom serialization, which uses both the Serializable and Externalizable interfaces.

Default serialization

To use default serialization, implement the java.io.Serializable interface, which includes the API that converts objects into bytes, which are later deserialized. Use the java.io.ObjectOutputStream class to persist the object. Then, call the ObjectOutputStream.writeObject() method to initiate serialization and flatten the Java object.

Custom serialization

Some cases exist where objects must be modified to use custom serialization, such as implementing the java.io.Externalizable interface or by implementing the writeObject and readObject methods for classes implementing the java.io.Serializable interface. Custom serialization techniques should be employed when the objects are serialized using mechanisms other than the ObjectGrid API or EntityManager API methods.

For example, when objects or entities are stored as instance data in a DataGrid API agent or the agent returns objects or entities, those objects are not transformed using an ObjectTransformer. The agent, will however, automatically use the ObjectTransformer when using EntityMixin interface. See DataGrid agents and entity based Maps for further details.