• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XML Serialization of POJOs?

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've been evaluation various Java <-> XML solutions as a way to serialize existing java domain objects (containing data AND behavior) to/from XML.
I started with this doc as a starting point:
http://www.rpbourret.com/xml/XMLDataBinding.htm
And narrowed the list down from 40+ candidates to 10 contenders:
1. Castor, looks great
2. JAXB, Strong candidate based on standardness
3. JaxMe, alternative JAXB implementation
4. Jbind, but note bad performance in XML in Java: Data binding, Part 2: Performance
5. JiBX, fairly simple, clean XML output, uses byte-code instrumentation
6. Xgen, built on Castor
7. Zeus
8. Betwixt
9. KBML (Koala Bean Markup Language), KOML (Koala Object Markup Language), marginal survivor � no schema support?
10. XMLBeans
The examples I've seen of JAXB center around using an XSD as a starting point. In addition the java objects created are simple javabean-like value objects, with no behavior.
I'm starting with java objects not an XSD. I'm happy to create an XSD if needed. My dream though is to take my existing graph of domain objects and "XML-enable" them using one of these technologies.
Can JAXB fill this need? Can my domain objects extend the JAXB-generated classes perhaps, thus allowing me to keep my coded behavior? Or is there some other way to XML-enable my classes?
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by John Lindwall:
allowing me to keep my coded behavior?


Are you really talking about serializing the class' bytecode into the resulting XML document? I can't see any other way of serializing the object's "behavior" to an XML document.
Most XML data binding solutions are based on the assumption that whoever deserializes the XML documents back into Java objects already have the Java class somewhere in the classpath -- thus, the behavior is already present and the XML document only contains the object's state.
PS. If you don't like complexity, take XStream for a test ride!
 
reply
    Bookmark Topic Watch Topic
  • New Topic