aspose 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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
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: 199
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: 17249
    
    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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Improving performance of JAXBContext init by using Spring singleton or prototype scope?
 
Similar Threads
Making a bean as Stateful using spring
what will be bean's scope?
Singleton vs prototype
FactoryBean's isSingleton()
Bean Scope: Prototype Vs Singleton