...
What I definitively like is the backwards and forward compatibility that these two libraries provide, that is there out of the box if some basic rules are followed. Compatibility is achieved, by associating number with fields (see the sample definition code). Thus, new fields can be added to the definition with our any problems, and when field should be removed in the new class version, the definition just has to keep the old field, so that old data can also be read (but this field will be ignored).
Although they are quite simple, I found a nice table that compares the two libraries:
...
This would be the last solution, thus using no additional libraries. It should provide very fast serialization, but requires a lot of work and can be error prone also.
It consists of making all our classes implement Externalizable interface, thus implementing these methods:
Code Block |
---|
public void writeExternal(ObjectOutput out) throws IOException; |
...
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException; |
In this methods we have to create a byte array on our own using some basic methods provided in the ObjectOutput class.
I don't see any advantage to the option number 2 with Kryo library. Forward and backward compatibility also needs to be created. Thus, I think that there is no reason to consider it as a valid option for us.
...