Browse Source

Polishing

pull/931/head
Juergen Hoeller 10 years ago
parent
commit
799a03e98d
  1. 5
      spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java
  2. 34
      spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBean.java
  3. 2
      spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java
  4. 2
      spring-websocket/src/main/java/org/springframework/web/socket/server/support/DefaultHandshakeHandler.java

5
spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperBuilder.java

@ -66,7 +66,7 @@ import org.springframework.util.StringUtils; @@ -66,7 +66,7 @@ import org.springframework.util.StringUtils;
* <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, 2.3 and 2.4; compatible with Jackson 2.0 and higher.
* <p>Tested against Jackson 2.2, 2.3, 2.4 and 2.5; compatible with Jackson 2.0 and higher.
*
* @author Sebastien Deleuze
* @author Juergen Hoeller
@ -451,6 +451,7 @@ public class Jackson2ObjectMapperBuilder { @@ -451,6 +451,7 @@ public class Jackson2ObjectMapperBuilder {
* @see #modulesToInstall(Module...)
* @see com.fasterxml.jackson.databind.Module
*/
@SuppressWarnings("unchecked")
public Jackson2ObjectMapperBuilder modulesToInstall(Class<? extends Module>... modules) {
this.moduleClasses = modules;
this.findWellKnownModules = true;
@ -500,6 +501,7 @@ public class Jackson2ObjectMapperBuilder { @@ -500,6 +501,7 @@ public class Jackson2ObjectMapperBuilder {
return this;
}
/**
* Build a new {@link ObjectMapper} instance.
* <p>Each build operation produces an independent {@link ObjectMapper} instance.
@ -682,7 +684,6 @@ public class Jackson2ObjectMapperBuilder { @@ -682,7 +684,6 @@ public class 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);
}

34
spring-web/src/main/java/org/springframework/http/converter/json/Jackson2ObjectMapperFactoryBean.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2015 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -118,7 +118,7 @@ import org.springframework.context.ApplicationContextAware; @@ -118,7 +118,7 @@ import org.springframework.context.ApplicationContextAware;
* 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, 2.3 and 2.4; compatible with Jackson 2.0 and higher.
* <p>Tested against Jackson 2.2, 2.3, 2.4 and 2.5; compatible with Jackson 2.0 and higher.
*
* @author <a href="mailto:dmitry.katsubo@gmail.com">Dmitry Katsubo</a>
* @author Rossen Stoyanchev
@ -346,6 +346,7 @@ public class Jackson2ObjectMapperFactoryBean implements FactoryBean<ObjectMapper @@ -346,6 +346,7 @@ public class Jackson2ObjectMapperFactoryBean implements FactoryBean<ObjectMapper
* @since 4.0.1
* @see com.fasterxml.jackson.databind.Module
*/
@SuppressWarnings("unchecked")
public void setModulesToInstall(Class<? extends Module>... modules) {
this.builder.modulesToInstall(modules);
}
@ -363,6 +364,11 @@ public class Jackson2ObjectMapperFactoryBean implements FactoryBean<ObjectMapper @@ -363,6 +364,11 @@ public class Jackson2ObjectMapperFactoryBean implements FactoryBean<ObjectMapper
this.builder.findModulesViaServiceLoader(findModules);
}
@Override
public void setBeanClassLoader(ClassLoader beanClassLoader) {
this.builder.moduleClassLoader(beanClassLoader);
}
/**
* Customize the construction of Jackson handlers ({@link JsonSerializer}, {@link JsonDeserializer},
* {@link KeyDeserializer}, {@code TypeResolverBuilder} and {@code TypeIdResolver}).
@ -373,14 +379,20 @@ public class Jackson2ObjectMapperFactoryBean implements FactoryBean<ObjectMapper @@ -373,14 +379,20 @@ public class Jackson2ObjectMapperFactoryBean implements FactoryBean<ObjectMapper
this.builder.handlerInstantiator(handlerInstantiator);
}
/**
* Set the builder {@link ApplicationContext} in order to autowire Jackson handlers ({@link JsonSerializer},
* {@link JsonDeserializer}, {@link KeyDeserializer}, {@code TypeResolverBuilder} and {@code TypeIdResolver}).
* @since 4.1.3
* @see Jackson2ObjectMapperBuilder#applicationContext(ApplicationContext)
* @see SpringHandlerInstantiator
*/
@Override
public void setBeanClassLoader(ClassLoader beanClassLoader) {
this.builder.moduleClassLoader(beanClassLoader);
public void setApplicationContext(ApplicationContext applicationContext) {
this.builder.applicationContext(applicationContext);
}
@Override
@SuppressWarnings("unchecked")
public void afterPropertiesSet() {
if (this.objectMapper != null) {
this.builder.configure(this.objectMapper);
@ -390,18 +402,6 @@ public class Jackson2ObjectMapperFactoryBean implements FactoryBean<ObjectMapper @@ -390,18 +402,6 @@ public class Jackson2ObjectMapperFactoryBean implements FactoryBean<ObjectMapper
}
}
/**
* Set the builder {@link ApplicationContext} in order to autowire Jackson handlers ({@link JsonSerializer},
* {@link JsonDeserializer}, {@link KeyDeserializer}, {@code TypeResolverBuilder} and {@code TypeIdResolver}).
* @since 4.1.3
* @see Jackson2ObjectMapperBuilder#applicationContext(ApplicationContext)
* @see SpringHandlerInstantiator
*/
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
this.builder.applicationContext(applicationContext);
}
/**
* Return the singleton ObjectMapper.
*/

2
spring-websocket/src/main/java/org/springframework/web/socket/server/jetty/JettyRequestUpgradeStrategy.java

@ -50,7 +50,7 @@ import org.springframework.web.socket.server.HandshakeFailureException; @@ -50,7 +50,7 @@ import org.springframework.web.socket.server.HandshakeFailureException;
import org.springframework.web.socket.server.RequestUpgradeStrategy;
/**
* A {@link RequestUpgradeStrategy} for use with Jetty 9.x. Based on Jetty's
* A {@link RequestUpgradeStrategy} for use with Jetty 9.0-9.2. Based on Jetty's
* internal {@code org.eclipse.jetty.websocket.server.WebSocketHandler} class.
*
* @author Phillip Webb

2
spring-websocket/src/main/java/org/springframework/web/socket/server/support/DefaultHandshakeHandler.java

@ -54,7 +54,7 @@ import org.springframework.web.socket.server.RequestUpgradeStrategy; @@ -54,7 +54,7 @@ import org.springframework.web.socket.server.RequestUpgradeStrategy;
* <p>If the negotiation succeeds, the actual upgrade is delegated to a server-specific
* {@link org.springframework.web.socket.server.RequestUpgradeStrategy}, which will update
* the response as necessary and initialize the WebSocket. Currently supported servers are
* Jetty 9.x, Tomcat 7.0.47+ and 8.x, Undertow 1.0-1.2, GlassFish 4.1+, WebLogic 12.1.3+.
* Jetty 9.0-9.2, Tomcat 7.0.47+ and 8.x, Undertow 1.0-1.2, GlassFish 4.1+, WebLogic 12.1.3+.
*
* @author Rossen Stoyanchev
* @author Juergen Hoeller

Loading…
Cancel
Save