[jdom-interest] Convert XML data to Java ojbects
guyn at tantian.com
Wed Sep 6 01:21:27 PDT 2000
> OK. Makes sense. Now could you explain (to others) why you would use
> your methodology instead of data binding? Data Binding would create the
> Person class for you, create the Address class for you, and then using a
> Marshaller and Unmarshaller, convert back and forth. There wouldn't be a
> need for this, if you used data binding... let us know what use case
> this fills that a more standard methodoogy doesn't.
I'm working in a J2EE environment. The data that is roaming in the system is
XML. I needed a way to map XML to EntityBeans in both directions.
At first I realized that I'm adding a toXML() method to every EntityBean. I
needed a more generic way of doing that. This resulted in a generic
converter from EntityBean to XML.
In the opposite direction - constructing EntityBean out of XML was a much
more complex problem. At first I looked at the solution of Data Binding. The
problem was that EntityBeans should not be created at run time. EntityBeans
are coded and than deployed to an Enterprise Container. I needed a way to
map XML to predefined EntityBean objects.
While coding this generic mapping - I realized that it's good enough not
just to EJB's but also to other standard Java objects.
Currently I find it very useful. I took a design approach that enables one
to extend the basic functionality of the conversion to whatever needed by
scenario (EJB's among other scenarios)
More information about the jdom-interest