Remove JDK 1.7 guards
This commit is contained in:
@@ -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
|
||||
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;
|
||||
*/
|
||||
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 {
|
||||
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));
|
||||
|
||||
@@ -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;
|
||||
*/
|
||||
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 {
|
||||
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler();
|
||||
scheduler.setThreadNamePrefix("SockJS-");
|
||||
scheduler.setPoolSize(Runtime.getRuntime().availableProcessors());
|
||||
if (hasRemoveOnCancelPolicyMethod) {
|
||||
scheduler.setRemoveOnCancelPolicy(true);
|
||||
}
|
||||
scheduler.setRemoveOnCancelPolicy(true);
|
||||
return scheduler;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
*/
|
||||
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
|
||||
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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user