Browse Source

Remove JDK 1.7 guards

pull/579/head
Rossen Stoyanchev 12 years ago
parent
commit
6438209557
  1. 11
      spring-websocket/src/main/java/org/springframework/web/socket/config/WebSocketNamespaceUtils.java
  2. 12
      spring-websocket/src/main/java/org/springframework/web/socket/config/annotation/WebSocketConfigurationSupport.java
  3. 13
      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

@ -16,7 +16,6 @@ @@ -16,7 +16,6 @@
package org.springframework.web.socket.config;
import org.springframework.util.ClassUtils;
import org.w3c.dom.Element;
import org.springframework.beans.factory.config.BeanDefinition;
@ -32,8 +31,6 @@ import org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsSe @@ -32,8 +31,6 @@ import org.springframework.web.socket.sockjs.transport.TransportHandlingSockJsSe
import org.springframework.web.socket.sockjs.transport.handler.DefaultSockJsService;
import org.springframework.web.socket.sockjs.transport.handler.WebSocketTransportHandler;
import java.util.concurrent.ScheduledThreadPoolExecutor;
/**
* Provides utility methods for parsing common WebSocket XML namespace elements.
*
@ -43,10 +40,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -43,10 +40,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
*/
class WebSocketNamespaceUtils {
// Check for setRemoveOnCancelPolicy method - available on JDK 7 and higher
private static boolean hasRemoveOnCancelPolicyMethod = ClassUtils.hasMethod(
ScheduledThreadPoolExecutor.class, "setRemoveOnCancelPolicy", boolean.class);
public static RuntimeBeanReference registerHandshakeHandler(Element element, ParserContext parserContext, Object source) {
RuntimeBeanReference handlerRef;
@ -147,9 +140,7 @@ class WebSocketNamespaceUtils { @@ -147,9 +140,7 @@ class WebSocketNamespaceUtils {
taskSchedulerDef.setSource(source);
taskSchedulerDef.setRole(BeanDefinition.ROLE_INFRASTRUCTURE);
taskSchedulerDef.getPropertyValues().add("poolSize", Runtime.getRuntime().availableProcessors());
if (hasRemoveOnCancelPolicyMethod) {
taskSchedulerDef.getPropertyValues().add("removeOnCancelPolicy", true);
}
taskSchedulerDef.getPropertyValues().add("removeOnCancelPolicy", true);
taskSchedulerDef.getPropertyValues().add("threadNamePrefix", schedulerName + "-");
parserContext.getRegistry().registerBeanDefinition(schedulerName, taskSchedulerDef);
parserContext.registerComponent(new BeanComponentDefinition(taskSchedulerDef, schedulerName));

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

@ -18,12 +18,9 @@ package org.springframework.web.socket.config.annotation; @@ -18,12 +18,9 @@ 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;
import org.springframework.web.servlet.handler.AbstractHandlerMapping;
import java.util.concurrent.ScheduledThreadPoolExecutor;
/**
* Configuration support for WebSocket request handling.
*
@ -32,11 +29,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -32,11 +29,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
*/
public class WebSocketConfigurationSupport {
// Check for setRemoveOnCancelPolicy method - available on JDK 7 and higher
private static boolean hasRemoveOnCancelPolicyMethod = ClassUtils.hasMethod(
ScheduledThreadPoolExecutor.class, "setRemoveOnCancelPolicy", boolean.class);
@Bean
public HandlerMapping webSocketHandlerMapping() {
ServletWebSocketHandlerRegistry registry = new ServletWebSocketHandlerRegistry(defaultSockJsTaskScheduler());
@ -71,9 +63,7 @@ public class WebSocketConfigurationSupport { @@ -71,9 +63,7 @@ public class WebSocketConfigurationSupport {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setThreadNamePrefix("SockJS-");
scheduler.setPoolSize(Runtime.getRuntime().availableProcessors());
if (hasRemoveOnCancelPolicyMethod) {
scheduler.setRemoveOnCancelPolicy(true);
}
scheduler.setRemoveOnCancelPolicy(true);
return scheduler;
}

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

@ -18,16 +18,12 @@ package org.springframework.web.socket.config.annotation; @@ -18,16 +18,12 @@ package org.springframework.web.socket.config.annotation;
import org.springframework.context.annotation.Bean;
import org.springframework.messaging.simp.config.AbstractMessageBrokerConfiguration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
import org.springframework.messaging.simp.user.UserSessionRegistry;
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;
import java.util.concurrent.ScheduledThreadPoolExecutor;
/**
* Extends {@link AbstractMessageBrokerConfiguration} and adds configuration for
* receiving and responding to STOMP messages from WebSocket clients.
@ -41,11 +37,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor; @@ -41,11 +37,6 @@ import java.util.concurrent.ScheduledThreadPoolExecutor;
*/
public abstract class WebSocketMessageBrokerConfigurationSupport extends AbstractMessageBrokerConfiguration {
// Check for setRemoveOnCancelPolicy method - available on JDK 7 and higher
private static boolean hasRemoveOnCancelPolicyMethod = ClassUtils.hasMethod(
ScheduledThreadPoolExecutor.class, "setRemoveOnCancelPolicy", boolean.class);
private WebSocketTransportRegistration transportRegistration;
@ -105,9 +96,7 @@ public abstract class WebSocketMessageBrokerConfigurationSupport extends Abstrac @@ -105,9 +96,7 @@ public abstract class WebSocketMessageBrokerConfigurationSupport extends Abstrac
public ThreadPoolTaskScheduler messageBrokerSockJsTaskScheduler() {
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
scheduler.setPoolSize(Runtime.getRuntime().availableProcessors());
if (hasRemoveOnCancelPolicyMethod) {
scheduler.setRemoveOnCancelPolicy(true);
}
scheduler.setRemoveOnCancelPolicy(true);
scheduler.setThreadNamePrefix("MessageBrokerSockJS-");
return scheduler;
}

Loading…
Cancel
Save