What is the way to specify Class Instance based JAXB Listener (as in Entity Bean) like : afterUnmarshall , beforeMarshall but on every class instance based (by implementing any interface or by annotation).
@XmlRootElement(name = "Person") // Edited
public class Person {
protected String name; //setter getter also implemented
void beforeMarshall(){
//..........
}
void afterUnmarshall (){ // by implementing any interface or by annotation
//..........
}
}
JAXB will match the following method signatures for those events:
// This method is called immediately after the object is created and before the unmarshalling of this
// object begins. The callback provides an opportunity to initialize JavaBean properties prior to unmarshalling.
void beforeUnmarshal(Unmarshaller, Object parent);
//This method is called after all the properties (except IDREF) are unmarshalled for this object,
//but before this object is set to the parent object.
void afterUnmarshal(Unmarshaller, Object parent);
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