my dog learned polymorphism*
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
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: 8904

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: 8904

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question on JAXB
 
Similar Threads
Java and XML
Isolation levels in a transaction
extending or instantiating JAXB factory?
problem on using jwsdp to generate java class
compare two XML files using DOM parser