1

Folks,

I am trying to implement an automatic substitution of JAXB objects with their overloaded customized versions the way it is described in this article:

https://jaxb.java.net/guide/Adding_behaviors.html

The problem is that this article is talking about JAXB 1.0 and same mechanism simply does not work in 2.0. The unmarshaller just loads the schema defined object in the object hierarchy, and not the extension of this object and ObjectFactory class appears to be simply ignored.

There has to be a way to do what was described in the article above in JAXB 2.0. I cannot seem to figure it out. Maybe I need to use xjb file to define this behavior or something like that. Any thoughts are appreciated.

Thanks

Nikita Visnevski
  • 147
  • 2
  • 11
  • See this: http://stackoverflow.com/questions/26439184/why-is-the-objectfactory-not-used-during-unmarshalling – lexicore Dec 14 '16 at 14:46

1 Answers1

0

Looks like the best way to do it is to customize the binding with xjb file and have it include the following content:

<jxb:bindings node="//xs:complexType[@name='MyClassDataType']">
    <jxb:class implClass="my.package.MyClassType"/>
</jxb:bindings>    

or

<jxb:bindings node="//xs:element[@name='MyClassData']">
    <jxb:class implClass="my.package.MyClass"/>
</jxb:bindings>

This seems to take care of my needs.

Nikita Visnevski
  • 147
  • 2
  • 11