This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
In our work we are using XStream to marshal/unmarshall for RESTful resources.Here XStream exactly behaves like JAXB except different annotatons. They say XStream is aserialization frame and should not be confused with JAXB which is binding frame work.
Does anyone clarify the differnece between these two please..
Serialization, to me, is when you from an object create a data representation of that object that, for instance, can be transferred using some means of communication.
With serialization, the object is the "mould" to create the serialized data from - the object is introspected and the data it contains is extracted.
If the class of the object changes, it still can be serialized without having to change any code or re-generating anything.
The serial representations before and after the change may not be compatible, but that is another issue.
With JAXB, an XML schema is the "mould" that specifies how the representation of an object is to look like.
From the XML schema, one or more JAXB bean classes are created. These JAXB bean classes are the Java representation of the data structure specified by the XML schema.
The JAXB framework then can transfer from XML data to an object structure that consists of instances of JAXB bean classes or vice versa.
If the XML schema changes, you typically have to re-generate the JAXB bean classes.
I think the basic difference is: What is first?
With serialization, it is an object. With JAXB, it is an XML schema.
Hope this makes sense.
But without any XML Schema, i can annotate my simple POJO with JAXB annotations and using JAXB context i can marshal this object to XML representation which is exactly we are doing in XStream also. so if JAXB is only the binding framework does it mean that it wont take burden of serialization process instead it simply maps the xml nodes to bean properties?, i mean underlying JAX-WS will take care of this serialization while in the SOAP response?
I must admit that I am not familiar with XStream.
JAXB is the framework responsible for transforming XML to a Java object structure and vice versa when using JAX-WS.
JAX-RPC has a serialization mechanism built in to the framework, but with JAX-WS this was extracted to a framework that can be used independent of JAX-WS.
JAXB uses the metadata (annotations) in the JAXB bean classes in order to know in which field to put what part of the XML data and the other way around.
Perhaps there is not that much of a difference between XStream and JAXB apart from words used when talking about one or the other...
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
subject: Difference between (Java to XML) binding and serialization, JAXB and XStream