diff --git a/spring-web/src/main/java/org/springframework/web/context/support/JacksonObjectMapperFactoryBean.java b/spring-web/src/main/java/org/springframework/http/converter/json/JacksonObjectMapperFactoryBean.java
similarity index 83%
rename from spring-web/src/main/java/org/springframework/web/context/support/JacksonObjectMapperFactoryBean.java
rename to spring-web/src/main/java/org/springframework/http/converter/json/JacksonObjectMapperFactoryBean.java
index cd0ef6b7253..765e174255b 100644
--- a/spring-web/src/main/java/org/springframework/web/context/support/JacksonObjectMapperFactoryBean.java
+++ b/spring-web/src/main/java/org/springframework/http/converter/json/JacksonObjectMapperFactoryBean.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package org.springframework.web.context.support;
+package org.springframework.http.converter.json;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
@@ -27,7 +27,7 @@ import org.codehaus.jackson.map.AnnotationIntrospector;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.SerializationConfig;
-import org.springframework.beans.FatalBeanException;
+
import org.springframework.beans.factory.FactoryBean;
import org.springframework.beans.factory.InitializingBean;
@@ -79,12 +79,8 @@ import org.springframework.beans.factory.InitializingBean;
* </bean>
*
*
- *
Note: This BeanFctory is singleton, so if you need more than one, you'll
- * need to configure multiple instances.
- *
* @author Dmitry Katsubo
* @author Rossen Stoyanchev
- *
* @since 3.2
*/
public class JacksonObjectMapperFactoryBean implements FactoryBean, InitializingBean {
@@ -97,6 +93,7 @@ public class JacksonObjectMapperFactoryBean implements FactoryBean
private DateFormat dateFormat;
+
/**
* Set the ObjectMapper instance to use.
* If not set an instance will be created using the default constructor.
@@ -135,8 +132,8 @@ public class JacksonObjectMapperFactoryBean implements FactoryBean
* {@link DeserializationConfig.Feature#AUTO_DETECT_FIELDS}.
*/
public void setAutoDetectFields(boolean autoDetectFields) {
- this.features.put(DeserializationConfig.Feature.AUTO_DETECT_FIELDS, Boolean.valueOf(autoDetectFields));
- this.features.put(SerializationConfig.Feature.AUTO_DETECT_FIELDS, Boolean.valueOf(autoDetectFields));
+ this.features.put(DeserializationConfig.Feature.AUTO_DETECT_FIELDS, autoDetectFields);
+ this.features.put(SerializationConfig.Feature.AUTO_DETECT_FIELDS, autoDetectFields);
}
/**
@@ -144,22 +141,22 @@ public class JacksonObjectMapperFactoryBean implements FactoryBean
* {@link DeserializationConfig.Feature#AUTO_DETECT_SETTERS}.
*/
public void setAutoDetectGettersSetters(boolean autoDetectGettersSetters) {
- this.features.put(SerializationConfig.Feature.AUTO_DETECT_GETTERS, Boolean.valueOf(autoDetectGettersSetters));
- this.features.put(DeserializationConfig.Feature.AUTO_DETECT_SETTERS, Boolean.valueOf(autoDetectGettersSetters));
+ this.features.put(SerializationConfig.Feature.AUTO_DETECT_GETTERS, autoDetectGettersSetters);
+ this.features.put(DeserializationConfig.Feature.AUTO_DETECT_SETTERS, autoDetectGettersSetters);
}
/**
* Shortcut for {@link SerializationConfig.Feature#FAIL_ON_EMPTY_BEANS}.
*/
public void setFailOnEmptyBeans(boolean failOnEmptyBeans) {
- this.features.put(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, Boolean.valueOf(failOnEmptyBeans));
+ this.features.put(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, failOnEmptyBeans);
}
/**
* Shortcut for {@link SerializationConfig.Feature#INDENT_OUTPUT}.
*/
public void setIndentOutput(boolean indentOutput) {
- this.features.put(SerializationConfig.Feature.INDENT_OUTPUT, Boolean.valueOf(indentOutput));
+ this.features.put(SerializationConfig.Feature.INDENT_OUTPUT, indentOutput);
}
/**
@@ -170,11 +167,10 @@ public class JacksonObjectMapperFactoryBean implements FactoryBean
* @see JsonGenerator.Feature
*/
public void setFeaturesToEnable(Object[] featuresToEnable) {
- if (featuresToEnable == null) {
- throw new FatalBeanException("featuresToEnable property should not be null");
- }
- for (Object feature : featuresToEnable) {
- this.features.put(feature, Boolean.TRUE);
+ if (featuresToEnable != null) {
+ for (Object feature : featuresToEnable) {
+ this.features.put(feature, Boolean.TRUE);
+ }
}
}
@@ -186,47 +182,28 @@ public class JacksonObjectMapperFactoryBean implements FactoryBean
* @see JsonGenerator.Feature
*/
public void setFeaturesToDisable(Object[] featuresToDisable) {
- if (featuresToDisable == null) {
- throw new FatalBeanException("featuresToDisable property should not be null");
+ if (featuresToDisable != null) {
+ for (Object feature : featuresToDisable) {
+ this.features.put(feature, Boolean.FALSE);
+ }
}
- for (Object feature : featuresToDisable) {
- this.features.put(feature, Boolean.FALSE);
- }
- }
-
- public ObjectMapper getObject() {
- return this.objectMapper;
}
- public Class> getObjectType() {
- return ObjectMapper.class;
- }
- public boolean isSingleton() {
- return true;
- }
-
- /**
- * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
- */
- public void afterPropertiesSet() throws FatalBeanException {
+ public void afterPropertiesSet() {
if (this.objectMapper == null) {
this.objectMapper = new ObjectMapper();
}
-
if (this.annotationIntrospector != null) {
this.objectMapper.getSerializationConfig().setAnnotationIntrospector(annotationIntrospector);
this.objectMapper.getDeserializationConfig().setAnnotationIntrospector(annotationIntrospector);
}
-
if (this.dateFormat != null) {
- // Deprecated for 1.8+, use
- // objectMapper.setDateFormat(dateFormat);
+ // Deprecated for 1.8+, use objectMapper.setDateFormat(dateFormat);
this.objectMapper.getSerializationConfig().setDateFormat(this.dateFormat);
}
-
- for (Map.Entry