Store reference to jaxbcontext in case implementations dont cache contexts
as the factory function would suggest.
@@ -8,12 +8,20 @@ import javax.xml.transform.stream.StreamSource;
public class JaxbConfigFactory implements ConfigFactory {
+ private final JAXBContext jaxbContext;
+
+ public JaxbConfigFactory() {
+ try {
+ this.jaxbContext = JAXBContext.newInstance(Config.class);
+ } catch (JAXBException ex) {
+ throw new ConfigException(ex);
+ }
+ }
@Override
public Config create(InputStream inputStream) {
try {
- JAXBContext jaxbContext = JAXBContext.newInstance(Config.class);
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
unmarshaller.setProperty("eclipselink.media-type", "application/json");
unmarshaller.setProperty("eclipselink.json.include-root", false);
