Refactoring After Event Serialization and EventUpcasters

Hi all,

After a series of events are stored, I need to do some refactorings to
event classes. I have to rename some classes & packages. I guess this
would make the deserialization attempts fail later since the
serialized classes would no longer be found in the classpath. Would
EventUpcasters be helpful in this case ?

Thanks & Regards,


Hi Setya,

if your changes are simple enough, you could use XStream’s alias and packageAlias features. These features allow for some changes, but are quite limited. For anything more than that, the EventUpcaster is the ideal mechanism. You can do virtually anything in them, since you just modify the xml structure before XStream deserializes it.

Keep in mind that you can use the “eventRevision” attribute in the XML to easilly decide whether an upcaster should do anything. The default value is 0 (for the first revision of the event). You can set another value by calling setEventRevision(…) in your event’s constructor. This mechanism isn’t mandatory, but might be useful in many cases.



I created a VersioningEventSerializer (
) that can convert old versions into newer ones.

It uses the small SerialVer4J library that currently supports Hessian,
Burlap and XStream as formats:

Here is an example how it works: