Use cache JAXBContext or Marshaller/Unmarshaller in local beans.
Sample:
private SoftReference<Unmarshaller> refUnmarshaller;
private Unmarshaller getUnmarshaller() throws JAXBException {
Unmarshaller um = refUnmarshaller != null ? refUnmarshaller.get() :
null;
if(um == null) {
JAXBContext jaxbContext = JAXBContext.newInstance(PACKAGE_NAME,
getClass().getClassLoader());
um = jaxbContext.createUnmarshaller();
refUnmarshaller = new SoftReference<Unmarshaller>(um);
}
return um;
}
Or sample (use Google Guava):
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
private static LoadingCache<Class<?>, JAXBContext> cache =
CacheBuilder.newBuilder()
.expireAfterAccess(10, TimeUnit.MINUTES)
.build(new CacheLoader<Class<?>, JAXBContext>() {
@Override
public JAXBContext load(Class<?> key) throws Exception {
return JAXBContext.newInstance(key);
}
});
JAXBContext jc = cache.get(cls);
--
View this message in context:
http://camel.465427.n5.nabble.com/Camel-Splitter-slowness-problem-tp5742307p5742333.html
Sent from the Camel - Users mailing list archive at Nabble.com.