Browse Source

Fix warnings from the sniff task

pull/573/head
Rossen Stoyanchev 12 years ago
parent
commit
cb40908a7d
  1. 11
      spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java
  2. 10
      spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationSupport.java
  3. 9
      spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupport.java

11
spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java

@ -17,6 +17,8 @@ @@ -17,6 +17,8 @@
package org.springframework.web.socket.config;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.util.ClassUtils;
import org.springframework.web.socket.config.annotation.WebSocketConfigurationSupport;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
@ -40,6 +42,11 @@ import org.springframework.web.socket.sockjs.transport.handler.WebSocketTranspor @@ -40,6 +42,11 @@ import org.springframework.web.socket.sockjs.transport.handler.WebSocketTranspor
*/
class WebSocketNamespaceUtils {
// Check for setRemoveOnCancelPolicy method - available on JDK 7 and higher
private static boolean hasRemoveOnCancelPolicyMethod = ClassUtils.hasMethod(
WebSocketConfigurationSupport.class, "setRemoveOnCancelPolicy", boolean.class);
public static RuntimeBeanReference registerHandshakeHandler(Element element, ParserContext parserContext, Object source) {
RuntimeBeanReference handlerRef;
Element handlerElem = DomUtils.getChildElementByTagName(element, "handshake-handler");
@ -140,7 +147,9 @@ class WebSocketNamespaceUtils { @@ -140,7 +147,9 @@ class WebSocketNamespaceUtils {
taskSchedulerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
taskSchedulerDef.getPropertyValues().add("poolSize", Runtime.getRuntime().availableProcessors());
taskSchedulerDef.getPropertyValues().add("threadNamePrefix", schedulerName + "-");
taskSchedulerDef.getPropertyValues().add("removeOnCancelPolicy", true);
if (hasRemoveOnCancelPolicyMethod) {
taskSchedulerDef.getPropertyValues().add("removeOnCancelPolicy", true);
}
parserContext.getRegistry().registerBeanDefinition(schedulerName, taskSchedulerDef);
parserContext.registerComponent(new BeanComponentDefinition(taskSchedulerDef, schedulerName));
}

10
spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationSupport.java

@ -18,6 +18,7 @@ package org.springframework.web.socket.config.annotation; @@ -18,6 +18,7 @@ package org.springframework.web.socket.config.annotation;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.util.ClassUtils;
import org.springframework.web.servlet.HandlerMapping;
/**
@ -28,6 +29,11 @@ import org.springframework.web.servlet.HandlerMapping; @@ -28,6 +29,11 @@ import org.springframework.web.servlet.HandlerMapping;
*/
public class WebSocketConfigurationSupport {
// Check for setRemoveOnCancelPolicy method - available on JDK 7 and higher
private static boolean hasRemoveOnCancelPolicyMethod = ClassUtils.hasMethod(
WebSocketConfigurationSupport.class, "setRemoveOnCancelPolicy", boolean.class);
@Bean
public HandlerMapping webSocketHandlerMapping() {
ServletWebSocketHandlerRegistry registry = new ServletWebSocketHandlerRegistry(defaultSockJsTaskScheduler());
@ -60,7 +66,9 @@ public class WebSocketConfigurationSupport { @@ -60,7 +66,9 @@ public class WebSocketConfigurationSupport {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setThreadNamePrefix("SockJS-");
scheduler.setPoolSize(Runtime.getRuntime().availableProcessors());
scheduler.setRemoveOnCancelPolicy(true);
if (hasRemoveOnCancelPolicyMethod) {
scheduler.setRemoveOnCancelPolicy(true);
}
return scheduler;
}

9
spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketMessageBrokerConfigurationSupport.java

@ -23,6 +23,7 @@ import org.springframework.context.annotation.Bean; @@ -23,6 +23,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.messaging.simp.SimpSessionScope;
import org.springframework.messaging.simp.config.AbstractMessageBrokerConfiguration;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.util.ClassUtils;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler;
@ -41,6 +42,10 @@ import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler; @@ -41,6 +42,10 @@ import org.springframework.web.socket.messaging.SubProtocolWebSocketHandler;
*/
public abstract class WebSocketMessageBrokerConfigurationSupport extends AbstractMessageBrokerConfiguration {
// Check for setRemoveOnCancelPolicy method - available on JDK 7 and higher
private static boolean hasRemoveOnCancelPolicyMethod = ClassUtils.hasMethod(
WebSocketConfigurationSupport.class, "setRemoveOnCancelPolicy", boolean.class);
private WebSocketTransportRegistration transportRegistration;
@ -98,7 +103,9 @@ public abstract class WebSocketMessageBrokerConfigurationSupport extends Abstrac @@ -98,7 +103,9 @@ public abstract class WebSocketMessageBrokerConfigurationSupport extends Abstrac
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setThreadNamePrefix("MessageBrokerSockJS-");
scheduler.setPoolSize(Runtime.getRuntime().availableProcessors());
scheduler.setRemoveOnCancelPolicy(true);
if (hasRemoveOnCancelPolicyMethod) {
scheduler.setRemoveOnCancelPolicy(true);
}
return scheduler;
}

Loading…
Cancel
Save