multiple JAXB serializations for one class?
Question
i have a Class A that is used as a result for a JAX-RS method. I want to marshal A into xml in two different ways.
Is there a way to give resteasy two different mappings to use on my class?
Greetings, Laures
Solution
Note: I'm the EclipseLink JAXB (MOXy) lead and a member of the JAXB 2 (JSR-222) expert group.
You could use MOXy for this. Check out my blog post where I map the same object model to two different weather services (Google and Yahoo) by leveraging annotations for one mapping and MOXy's XML metadata for the second mapping:
Below is an example of using MOXy's XML metadata in a JAX-RS environment:
For More Information
OTHER TIPS
Here is a solution for JAXB RI. The same idea: define JAXB annotations in XML resources.