提交 20a8416c 编写于 作者: J Juergen Hoeller

Jackson2ObjectMapperBuilder allows for regular constructor usage as well

Issue: SPR-12243
上级 3a3c52db
......@@ -56,7 +56,7 @@ import org.springframework.util.ClassUtils;
* <p>Note that Jackson's JSR-310 and Joda-Time support modules will be registered automatically
* when available (and when Java 8 and Joda-Time themselves are available, respectively).
*
* <p>Tested against Jackson 2.2 and 2.3; compatible with Jackson 2.0 and higher.
* <p>Tested against Jackson 2.2, 2.3 and 2.4; compatible with Jackson 2.0 and higher.
*
* @author Sebastien Deleuze
* @author Juergen Hoeller
......@@ -92,28 +92,6 @@ public class Jackson2ObjectMapperBuilder {
private ClassLoader moduleClassLoader = getClass().getClassLoader();
private Jackson2ObjectMapperBuilder() {
}
/**
* Obtain a {@link Jackson2ObjectMapperBuilder} instance in order to
* build an {@link ObjectMapper} instance.
*/
public static Jackson2ObjectMapperBuilder json() {
return new Jackson2ObjectMapperBuilder();
}
/**
* Obtain a {@link Jackson2ObjectMapperBuilder} instance in order to
* build a {@link XmlMapper} instance.
*/
@SuppressWarnings("unchecked")
public static Jackson2ObjectMapperBuilder xml() {
return new Jackson2ObjectMapperBuilder().createXmlMapper(true);
}
/**
* If set to {@code true}, an {@link XmlMapper} will be created using its
* default constructor. This is only applicable to {@link #build()} calls,
......@@ -499,4 +477,24 @@ public class Jackson2ObjectMapperBuilder {
}
}
// Convenience factory methods
/**
* Obtain a {@link Jackson2ObjectMapperBuilder} instance in order to
* build a regular JSON {@link ObjectMapper} instance.
*/
public static Jackson2ObjectMapperBuilder json() {
return new Jackson2ObjectMapperBuilder();
}
/**
* Obtain a {@link Jackson2ObjectMapperBuilder} instance in order to
* build an {@link XmlMapper} instance.
*/
@SuppressWarnings("unchecked")
public static Jackson2ObjectMapperBuilder xml() {
return new Jackson2ObjectMapperBuilder().createXmlMapper(true);
}
}
......@@ -112,7 +112,7 @@ import org.springframework.beans.factory.InitializingBean;
* Note that Jackson's JSR-310 and Joda-Time support modules will be registered automatically
* when available (and when Java 8 and Joda-Time themselves are available, respectively).
*
* <p>Tested against Jackson 2.2 and 2.3; compatible with Jackson 2.0 and higher.
* <p>Tested against Jackson 2.2, 2.3 and 2.4; compatible with Jackson 2.0 and higher.
*
* @author <a href="mailto:dmitry.katsubo@gmail.com">Dmitry Katsubo</a>
* @author Rossen Stoyanchev
......@@ -122,7 +122,7 @@ import org.springframework.beans.factory.InitializingBean;
*/
public class Jackson2ObjectMapperFactoryBean implements FactoryBean<ObjectMapper>, BeanClassLoaderAware, InitializingBean {
private final Jackson2ObjectMapperBuilder builder = Jackson2ObjectMapperBuilder.json();
private final Jackson2ObjectMapperBuilder builder = new Jackson2ObjectMapperBuilder();
private ObjectMapper objectMapper;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册