Upcasters: is in-place update OK?


I’m writing an event upcaster for an Axon 2 application. The events are stored in XML, and therefore I upcast by manipulating Document instances, just like the example in the guide (http://www.axonframework.org/docs/2.4/repositories-and-event-stores.html#event-upcasting).

I have doubts about the style of the DOM manipulation: the upcaster in the example creates the upcasted event as a modified copy of the old event; does this mean that in-place update is discouraged or wrong?

Kind regards,
Gianluca Ortelli

Hi Gianluca,

It’s been a while since that example was written, but if I recall correctly, the copying is necessary because you can’t just move en element to another location. That’s a Dom4J restriction. Therefore, a copy of an element is attached to its new location.

It’s fine to simply change the intermediate representation in-place. There is no need to treat them as immutable objects.



Thanks Allard,

good to know. That will avoid a lot of noise in the code.