By Juwit
via juwit.blogspot.com
Published: Nov 16 2009 / 14:55
JAXB (Java Architecture for XML Binding) is one of the JEE API. It permits to create a mapping between Java objects and XML elements, by annotating POJOs (Plain Old Java Objects), as it is done in JPA to create an object/database mapping. JAXB is mainly used in JAX-WS (Java API for XML Web Services) to handle SOAP messages and their content with java objects.
In this article, I propose another way to use JAXB to persist java objects. In many applications, it can be useful to persist objects in XML, for instance in desktop applications.



Comments
MCII replied ago:
"This part covers the annotation of existing classes to make them managable by JAXB. This approach has one major advantage : you don't have to write an XML Schema"
For JAXB generating code from a Schema is the gist. Avoiding the Schema is not an 'advantage'.
Julien Wittouck replied ago:
I agree, the word "advantage" isn't appropriate here. My point here was to show how to use existing classes (JPA-annotated ones for instance), and not re-generate them from a schema, avoiding erasing legacy code.
The best usage will be, of course, writing a schema and map it to the annotated classes.
Voters For This Link (15)
Voters Against This Link (0)