• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

UnMarshalling and Marshalling

 
kri shan
Ranch Hand
Posts: 1462
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am evaluating JAXB and Castor for UnMarshalling(XML-> Java Objects ) and Marshalling(Java Objects -> XML). Which gives better performance ?
 
Anurag Blore
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not sure about CASTOR but JAXB has performance issue when you have lot of data. I have faced it, the data gets returned in 2 second but while marshalling takes lot of time and gives us out of memory error. This could be due to the xml element names(more than 15 characters in some case) in my xsd.

 
Taariq San
Ranch Hand
Posts: 192
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also look at JIBX, if performance is a serious consideration.
 
kri shan
Ranch Hand
Posts: 1462
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Anurag, How xml element names more than 15 characters in xsd gives outOfMemoryError ?

 
Anurag Blore
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Krishan,

May be I was not clear in my post.

In my case we have a search and if user searched based on 2 characters then the reult returned from the database is huge and data is returned fast from the database but when we do marshalling in java It gives us heap error. Just to mention my xml result is quite complex(In the sense it has relations,attributes etc returned) So If I am returning detail of one result the xml will be big and multiple result will have more data to convert our java object to xml(marshalling). It my guess the xml contains lot of Strings attribute name and this could be the cause.

If you think I am missing something please providie your thoughts.
 
Hiren Dutta
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Vote will go for JAXB. With a little trick we can save lot of JAXB marshalling and unmarshalling time. JAXB spends most of the time to create JAXB context. We just have to make JAXBContext static final. If you are using multiple JAXBContext, create 1st time and keep in static Hashmap.
 
Bhaskar Rao
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I haven't evaluated JAXB for performance. But one advantage I found with CASTOR was that it does not mandate the use of XSDs.

Databases can return entire ResultSets as XML which you can then transform to whatever format you want using XSLT. But again, I am not sure if the transformation itself can throw OutOfMemoryError in your case
 
Carey Evans
Ranch Hand
Posts: 225
Debian Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JAXB doesn't need a schema; we're doing unmarshalling of a 6 MB file using JAXB, just by defining the appropriate classes with JAXB annotations. We only create the JAXBContext once.
 
Jegan Thangavelu
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I did some research on this and found that ,apache XMLBeans seems to be faster in marshalling and unmarshalling and also CPU utilization is less.

-Jegan
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18153
52
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Maybe I'm being unfair to Castor, but at one time it was the only game in town, and it did a good job. These days, you don't hear that much about it, so I'm thinking that it no longer is the optimal tool for most tasks. In fact, I think that the JOnAS project switched from Castor to Zeus, and then abandoned Zeus for something more along the lines of a mainstream standard.

Of course, there also seemed to be a certain amount of ill-will among some because Castor claimed the acronym JDO, despite the conflict with the real JDO, so some of that could be politics.

On the inbound side, the Apache Digester remains popular. I've also used STaX where I wanted directed streaming input.

Finally, there are some JPA implementations that can persist to/from XML, if that's useful.
 
Praveen Sharma
Ranch Hand
Posts: 129
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can have a look at this : http://xstream.codehaus.org/
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic