Home United States USA — software Migrate Serialized Java Objects with XStream and XMT

Migrate Serialized Java Objects with XStream and XMT

146
0
SHARE

Array
Join the DZone community and get the full member experience.
Java serialization is convenient to store the state of Java objects. However, there are some drawbacks of serialized data:
It is not human-readable.
It is Java-specific and is not exchangeable with other programming languages.
It is not migratable if fields of the associated Java class have been changed.
These drawbacks make Java serialization not a practical approach to storing object states for real-world projects. In a product developed recently, we use XStream to serialize/deserialize Java objects, which solves the first and second problems. The third problem is addressed with XMT, an open source tool developed by us to migrate XStream serialized XMLs. This article introduces this tool with some examples.
So many of the issues that we all run into when we are working on converting computer languages into something that can be better understood by human beings is the fact that computer languages need to be simplified if possible. 
These languages are great for the computers that speak back and forth with one another, but they don’t necessarily work out as well when humans try to become involved with them. Many humans end up confused and unable to make much progress at all on getting these systems cleared up. Thus, it is necessary to get them cleaned up and made more usable. There are people who are actively working on this problem right now, but in the meantime, we may simply have to deal with computers that can’t do everything we would like for them to do.
Assume a Task class below with a prioritized field indicating whether it is a prioritized task:
With XStream, we can serialize objects of this class to XML like below:
The resulting XML will be:
true
And you can deserialize the XML to get back task object:
Everything is fine.

Continue reading...