Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question on JAXB

 
Vijay K Vivek
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"JAXB generates interfaces representing the content (domain) objects. This means when it is time to create the object tree, you can't just instantiate these objects. You have to use the ObjectFactory created by JAXB to create each new object. This can be a bit tedious compared to creating other objects with a typical new. "

Recently Icame across an article on JAXB. The author makes the above observation. I do not understand why it is tedious to use a factory than a new.

For me both ways it is one single statement by itself.

Please shed me some light on the above.

PS:The article is available here. http://www.onjava.com/pub/a/onjava/2004/05/05/jaxb.html?page=4
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I am not wrong only the top level element needs to be created using factory. Check the samples in the jaxb download.
 
Pradeep bhatt
Ranch Hand
Posts: 8927
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Coming to your factory question. It is easier to use new rater than Factory. ... and also this is useful when some tools/frameworks require default constructor to create objects.
 
Vijay K Vivek
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your response Pradip.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic