Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JAXB objects to Transfer objects

 
Jim Janssens
Ranch Hand
Posts: 210
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In our project we have several services (ejb's) which can be invoked using XML. The story is like this:

[external client]--xml--[jaxb]--jaxb objects--[converter]---domain objects---[service]

[internal client]--domain objects---[service]

Thus, every service has its own domain objects. These objects are simple java beans (get/set) which describe the input fields to execute the service. We need this layer of independence because the service can also be called from inside.

So, the classes that jaxb generates to convert the XML to java need to be converter again to the domain objects. So the converter does basicly this:

domainObject.setName(jaxbObject.getName());
domainObject.setStreet(jaxbObject.getStreet());
etc...

For simple examples this may not seem a problem, but for comlex XML it becomes very error phrone to write such converter. It takes a long time to write it, test cases take even longer...

I feel like this conversion must be done automatically. Something like saying to JAXB to use our domain objects and not te generated ones...

Any one an idea ?
 
Nathaniel Stoddard
Ranch Hand
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why do you need both at all?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic