• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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

 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Politics n. Poly "many" + ticks "blood sucking insects". Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic