POF Coherence Serialization example
Serialization is the process where you encode object into binary format. Of-course if you are using Coherence to save/retrieve data will moved around the network. POF (Portable Object Format) basically is language agnostic binary format which has been designed to use efficiently to save and time and became cornerstone element while working with Coherence. There are many different wasy are available to serialize the object including standard java serialization also you could write you own custom serialize. Java serialization is easiest way to implement and preserve object identity. Once object got serialized then it can be read using any language. In below example we will use PofSerializer interface from Oracle Coherence which provide two abstract method “deserialize” and “serialize” which can be use to serialize the object.
We will serialize below type of data:
First create serializer for SampleModel.java because we will use this model to keep in HashMap while serializing big example:
- Create Enum class: EnumForSerializer.java:
- SerializationModelData.java: Main class with all type of data will be serialized:
- SampleModelDataSerializer.java – Main class where we are serializing the object: