Java JAXB类实例侦听器

Java JAXB类实例侦听器,java,xml-parsing,jaxb,jaxb2,Java,Xml Parsing,Jaxb,Jaxb2,指定基于类实例的JAXB侦听器(如在实体Bean中)的方法是什么,例如:afterUnmarshall、beforeMarshall但基于每个类实例(通过实现任何接口或注释) JAXB将为这些事件匹配以下方法签名: // This method is called immediately after the object is created and before the unmarshalling of this // object begins. The callback pr

指定基于类实例的JAXB侦听器(如在实体Bean中)的方法是什么,例如:afterUnmarshall、beforeMarshall但基于每个类实例(通过实现任何接口或注释)


JAXB将为这些事件匹配以下方法签名:

   // 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);

是否需要实现接口或仅指定这些方法签名?谢谢@Blaise,工作正常。不需要实现接口或注释。@userG-不需要实现任何接口,只需要方法签名即可。JAXB中没有与JPA事件注释等效的方法。是否也存在beforeMarshall()和afterMarshall()方法(我应用了这两个marshall侦听器,但不起作用)。
   // 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);