List of usage examples for com.fasterxml.jackson.databind MappingJsonFactory getCodec
public final ObjectMapper getCodec()
From source file:org.jberet.support.io.MappingJsonFactoryObjectFactory.java
/** * Gets an instance of {@code com.fasterxml.jackson.databind.MappingJsonFactory} based on the resource configuration * in the application server. The parameter {@code environment} contains MappingJsonFactory configuration properties, * and accepts the following properties: * <ul>/*from w w w.j a va 2 s .c o m*/ * <li>jsonFactoryFeatures: JsonFactory features as defined in com.fasterxml.jackson.core.JsonFactory.Feature * <li>mapperFeatures: ObjectMapper features as defined in com.fasterxml.jackson.databind.MapperFeature * <li>deserializationFeatures: * <li>serializationFeatures: * <li>customDeserializers: * <li>customSerializers: * <li>deserializationProblemHandlers: * <li>customDataTypeModules: * <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} * </ul> * * @param obj the JNDI name of {@code com.fasterxml.jackson.databind.MappingJsonFactory} 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.databind.MappingJsonFactory} * @throws Exception any exception occurred */ @Override public Object getObjectInstance(final Object obj, final Name name, final Context nameCtx, final Hashtable<?, ?> environment) throws Exception { MappingJsonFactory jsonFactory = jsonFactoryCached; if (jsonFactory == null) { synchronized (this) { jsonFactory = jsonFactoryCached; if (jsonFactory == null) { jsonFactoryCached = jsonFactory = new MappingJsonFactory(); } final ClassLoader classLoader = MappingJsonFactoryObjectFactory.class.getClassLoader(); final ObjectMapper objectMapper = jsonFactory.getCodec(); final Object jsonFactoryFeatures = environment.get("jsonFactoryFeatures"); if (jsonFactoryFeatures != null) { NoMappingJsonFactoryObjectFactory.configureJsonFactoryFeatures(jsonFactory, (String) jsonFactoryFeatures); } final Object mapperFeatures = environment.get("mapperFeatures"); if (mapperFeatures != null) { configureMapperFeatures(objectMapper, (String) mapperFeatures); } final Object deserializationFeatures = environment.get("deserializationFeatures"); if (deserializationFeatures != null) { configureDeserializationFeatures(objectMapper, (String) deserializationFeatures); } final Object serializationFeatures = environment.get("serializationFeatures"); if (serializationFeatures != null) { configureSerializationFeatures(objectMapper, (String) serializationFeatures); } final Object deserializationProblemHandlers = environment.get("deserializationProblemHandlers"); if (deserializationProblemHandlers != null) { configureDeserializationProblemHandlers(objectMapper, (String) deserializationProblemHandlers, classLoader); } configureCustomSerializersAndDeserializers(objectMapper, (String) environment.get("customSerializers"), (String) environment.get("customDeserializers"), (String) environment.get("customDataTypeModules"), classLoader); NoMappingJsonFactoryObjectFactory.configureInputDecoratorAndOutputDecorator(jsonFactory, environment); } } return jsonFactory; }