List of usage examples for com.fasterxml.jackson.dataformat.xml XmlFactory setCodec
public JsonFactory setCodec(ObjectCodec oc)
com.fasterxml.jackson.databind.ObjectMapper
) with this factory (and more importantly, parsers and generators it constructs). From source file:org.jberet.support.io.XmlFactoryObjectFactory.java
/** * Gets an instance of {@code com.fasterxml.jackson.dataformat.xml.XmlFactory} based on the resource configuration in the * application server. The parameter {@code environment} contains XmlFactory configuration properties, and accepts * the following properties://from w ww. j av a2s . com * <ul> * <li>inputDecorator: fully-qualified name of a class that extends {@code com.fasterxml.jackson.core.io.InputDecorator} * <li>outputDecorator: fully-qualified name of a class that extends {@code com.fasterxml.jackson.core.io.OutputDecorator} * <li>xmlTextElementName: * <li>defaultUseWrapper: * </ul> * * @param obj the JNDI name of {@code com.fasterxml.jackson.dataformat.xml.XmlFactory} resource * @param name always null * @param nameCtx always null * @param environment a {@code Hashtable} of configuration properties * @return an instance of {@code com.fasterxml.jackson.dataformat.xml.XmlFactory} * @throws Exception any exception occurred */ @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; }