Here you can find the source of getContext(Class> clazz)
private static JAXBContext getContext(Class<?> clazz)
//package com.java2s; //License from project: Open Source License import com.google.common.collect.Maps; import javax.xml.bind.*; import java.util.Map; public class Main { private static final Map<Class<?>, JAXBContext> CONTEXTS = Maps.newHashMap(); private static JAXBContext getContext(Class<?> clazz) { JAXBContext context = CONTEXTS.get(clazz); if (context == null) { try { context = JAXBContext.newInstance(clazz); } catch (JAXBException e) { throw new RuntimeException("Failed to create JAXBContext for type " + clazz, e); }/*w ww .j av a2s . co m*/ CONTEXTS.put(clazz, context); } return context; } }