@Override
public Object getObjectInstance(final Object obj,
final Name name,
final Context nameCtx,
final Hashtable<?, ?> environment) throws Exception {
XmlFactory xmlFactory = xmlFactoryCached;
if (xmlFactory == null) {
synchronized (this) {
xmlFactory = xmlFactoryCached;
if (xmlFactory == null) {
xmlFactoryCached = xmlFactory = new XmlFactory();
}
JacksonXmlModule xmlModule = null;
NoMappingJsonFactoryObjectFactory.configureInputDecoratorAndOutputDecorator(xmlFactory, environment);
final Object xmlTextElementName = environment.get("xmlTextElementName");
if (xmlTextElementName != null) {
xmlModule = new JacksonXmlModule();
xmlModule.setXMLTextElementName((String) xmlTextElementName);
}
final Object defaultUseWrapper = environment.get("defaultUseWrapper");
if (defaultUseWrapper != null) {
if (defaultUseWrapper.equals("false")) {
if (xmlModule == null) {
xmlModule = new JacksonXmlModule();
}
xmlModule.setDefaultUseWrapper(false);
} else if (defaultUseWrapper.equals("true")) {
//default value is already true, so nothing to do
} else {
throw SupportMessages.MESSAGES.invalidReaderWriterProperty(null, (String) defaultUseWrapper, "defaultUseWrapper");
}
}
final XmlMapper xmlMapper = xmlModule == null ? new XmlMapper(xmlFactory) : new XmlMapper(xmlFactory, xmlModule);
xmlFactory.setCodec(xmlMapper);
}
}
return xmlFactory;
}