How can I have JAXB call a method after it has completed unmarshalling an XML file into an object?

前端 未结 3 1313
有刺的猬
有刺的猬 2020-12-03 06:54

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.

3条回答
  •  旧时难觅i
    2020-12-03 07:41

    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

提交回复
热议问题