aspose file tools*
The moose likes XML and Related Technologies and the fly likes Question on JAXB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Question on JAXB" Watch "Question on JAXB" New topic
Author

Question on JAXB

Vijay K Vivek
Greenhorn

Joined: Oct 11, 2007
Posts: 27
"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

Joined: Feb 27, 2002
Posts: 8919

If I am not wrong only the top level element needs to be created using factory. Check the samples in the jaxb download.


Groovy
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

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

Joined: Oct 11, 2007
Posts: 27
Thanks for your response Pradip.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Question on JAXB