Generic helper class for serializing Java objects to and from simply-formatted XML
for archival and reconstitution across data definition versions.
XStream is used to handle the marshalling and unmarshalling work. The main
addition is an "externalizableVersion" attribute on the POJO's top-level
element. That attribute can then be checked for incompatibilities before
reconstitution, and used to convert old data into its new form. (Currently,
if there's a version mismatch and nothing is done about it, this class throws
a ConversionException.)
Translation to and from XML can be handled either with the static "toXML"
and "fromXML" methods, or through the Externalizable interface. The chief
benefit of the static methods is that they (theoretically) give subclasses
the ability to translate across versions using XSLT, and possibly even return
an object of a different class than the original.
TODO For the functionality being checked in (site-to-site migration), this class
is not strictly necessary. It's here on a speculative basis for upcoming
import/archive/merge development.
|