Software Development

JAXB – Perform Pre- and Post-processing with Unmarshaller.Listener

This post demonstrates how to perform pre- and post-processing with Unmarshaller.Listener. For instance you may want to compare the contents of an object before and after you unmarshal an XML. Another use-case is when you may need to store unmarshalled values to some list not mapped to any XML element. This is achieved by creating a class that extends Unmarshaller.Listener and overriding two (2) methods – beforeUnmarshal and afterUnmarshal.