Is there any way to map two links in a JAXB XML entity to different classes?
Example:
<restresource>
<atom:link rel="http://myuri/rels/author" href="http://myuri/users/42" title="That's me"/>
<atom:link rel="http://myuri/rels/customer" href="http://myuri/customers/4711" title="John Smith"/>
</restresource>
I’d like to map the first link with a XMLAdapter to the class User and the second one with a different XMLAdapter to class Customer. I tried to do that with @XmlPath from EclipseLink JAXB (MOXy). But didn’t got any result from a lot of experiments since it’s not possible to define a path with conditions on “rel”. I understand that this could only be done in combination with the Adaptor because otherwise the definition would not be bidirectional.
Any idea how to realize that?
We’ve added an extension to MOXy‘s @XmlPath that will make this use case easier to map. In EclipseLink 2.3 you will be able to do the following:
You can try this feature out today by downloading one of the EclipseLink 2.3.0 nightly downloads (starting March 22) from:
For more information
I will also try to put together an approach that is compatible with released versions of EclipseLink JAXB (MOXy).