File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Spring and the fly likes Improving performance of JAXBContext init by using Spring singleton or prototype scope? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Improving performance of JAXBContext init by using Spring singleton or prototype scope?" Watch "Improving performance of JAXBContext init by using Spring singleton or prototype scope?" New topic
Author

Improving performance of JAXBContext init by using Spring singleton or prototype scope?

Jay Dilla
Ranch Hand

Joined: Aug 12, 2004
Posts: 201
I have to unmarshal/marshal a lot of small XMLs, so I'm going to use JaxB. But getting the JAXBContext every time is going to be very expensive.

Instead of Caching through some kind of map I'm thinking of creating a bean for the JAXBContext initialization specifically, giving it singleton or prototype scope and then referencing that bean from the class that's going to manipulate the unmarshalled data. Different schemas could be passed each time so I guess I have to make it prototype scope actually.....

Does this make sense from a design perspective or is there a better way to do this?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17257
    
    6

Are you using spring-oxm? Which delegates to JAXB for you.

http://static.springsource.org/spring/docs/3.1.x/spring-framework-reference/html/oxm.html#oxm-jaxb

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Improving performance of JAXBContext init by using Spring singleton or prototype scope?