I am using JAXB to unmarshall an XML file into a Java object -- standard stuff. Once JAXB has completed this, I'd like a method to be called on the newly created object.
Is there a mechanism to do this? I'd prefer the object, not an external entity, do this to keep construction in one place.
Thanks.
You can simple add the following method to your object definition:
void afterUnmarshal(Unmarshaller u, Object parent) { ... }
It will be called once the current object has been completely deserialized. See also the documentation about unmarshalling callbacks
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With