Remove deprecated constructors in WebSocket config
In preparation for SPR-16189.
This commit is contained in:
@@ -21,7 +21,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
@@ -58,23 +57,6 @@ public abstract class AbstractWebSocketHandlerRegistration<M> implements WebSock
|
||||
@Nullable
|
||||
private SockJsServiceRegistration sockJsServiceRegistration;
|
||||
|
||||
@Nullable
|
||||
private TaskScheduler scheduler;
|
||||
|
||||
|
||||
public AbstractWebSocketHandlerRegistration() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated constructor with a TaskScheduler.
|
||||
* @deprecated as of 5.0 a TaskScheduler is not provided upfront, not until
|
||||
* it is obvious that it is needed, see {@link #getSockJsServiceRegistration()}.
|
||||
*/
|
||||
@Deprecated
|
||||
public AbstractWebSocketHandlerRegistration(TaskScheduler defaultTaskScheduler) {
|
||||
this.scheduler = defaultTaskScheduler;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public WebSocketHandlerRegistration addHandler(WebSocketHandler handler, String... paths) {
|
||||
@@ -115,9 +97,6 @@ public abstract class AbstractWebSocketHandlerRegistration<M> implements WebSock
|
||||
@Override
|
||||
public SockJsServiceRegistration withSockJS() {
|
||||
this.sockJsServiceRegistration = new SockJsServiceRegistration();
|
||||
if (this.scheduler != null) {
|
||||
this.sockJsServiceRegistration.setTaskScheduler(this.scheduler);
|
||||
}
|
||||
HandshakeInterceptor[] interceptors = getInterceptors();
|
||||
if (interceptors.length > 0) {
|
||||
this.sockJsServiceRegistration.setInterceptors(interceptors);
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.messaging.simp.config.MessageBrokerRegistry;
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0.1
|
||||
* @deprecated in favor of simply using {@link WebSocketMessageBrokerConfigurer}
|
||||
* @deprecated as of 5.0 in favor of simply using {@link WebSocketMessageBrokerConfigurer}
|
||||
* which has default methods, made possible by a Java 8 baseline.
|
||||
*/
|
||||
@Deprecated
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2018 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.
|
||||
@@ -18,7 +18,6 @@ package org.springframework.web.socket.config.annotation;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
@@ -41,22 +40,6 @@ public class ServletWebSocketHandlerRegistration
|
||||
extends AbstractWebSocketHandlerRegistration<MultiValueMap<HttpRequestHandler, String>> {
|
||||
|
||||
|
||||
public ServletWebSocketHandlerRegistration() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated constructor with a TaskScheduler for SockJS use.
|
||||
*
|
||||
* @deprecated as of 5.0 a TaskScheduler is not provided upfront, not until
|
||||
* it is obvious that it is needed, see {@link #getSockJsServiceRegistration()}.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecated")
|
||||
public ServletWebSocketHandlerRegistration(TaskScheduler scheduler) {
|
||||
super(scheduler);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected MultiValueMap<HttpRequestHandler, String> createMappings() {
|
||||
return new LinkedMultiValueMap<>();
|
||||
|
||||
@@ -20,10 +20,10 @@ import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.HttpRequestHandler;
|
||||
import org.springframework.web.servlet.handler.AbstractHandlerMapping;
|
||||
@@ -33,8 +33,8 @@ import org.springframework.web.socket.server.support.WebSocketHandlerMapping;
|
||||
import org.springframework.web.util.UrlPathHelper;
|
||||
|
||||
/**
|
||||
* A {@link WebSocketHandlerRegistry} that maps {@link WebSocketHandler WebSocketHandlerRegistry} that maps {@link WebSocketHandlers} to URLs for use
|
||||
* in a Servlet container.
|
||||
* {@link WebSocketHandlerRegistry} with Spring MVC handler mappings for the
|
||||
* handshake requests.
|
||||
*
|
||||
* @author Rossen Stoyanchev
|
||||
* @since 4.0
|
||||
@@ -43,9 +43,6 @@ public class ServletWebSocketHandlerRegistry implements WebSocketHandlerRegistry
|
||||
|
||||
private final List<ServletWebSocketHandlerRegistration> registrations = new ArrayList<>(4);
|
||||
|
||||
@Nullable
|
||||
private TaskScheduler scheduler;
|
||||
|
||||
private int order = 1;
|
||||
|
||||
@Nullable
|
||||
@@ -55,17 +52,6 @@ public class ServletWebSocketHandlerRegistry implements WebSocketHandlerRegistry
|
||||
public ServletWebSocketHandlerRegistry() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated constructor with a TaskScheduler for SockJS use.
|
||||
* @deprecated as of 5.0 a TaskScheduler is not provided upfront, not until
|
||||
* it is obvious that it is needed, see {@link #requiresTaskScheduler()} and
|
||||
* {@link #setTaskScheduler}.
|
||||
*/
|
||||
@Deprecated
|
||||
public ServletWebSocketHandlerRegistry(ThreadPoolTaskScheduler scheduler) {
|
||||
this.scheduler = scheduler;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public WebSocketHandlerRegistration addHandler(WebSocketHandler handler, String... paths) {
|
||||
@@ -114,18 +100,21 @@ public class ServletWebSocketHandlerRegistry implements WebSocketHandlerRegistry
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure a TaskScheduler for SockJS endpoints. This should be configured
|
||||
* before calling {@link #getHandlerMapping()} after checking if
|
||||
* {@link #requiresTaskScheduler()} returns {@code true}.
|
||||
* Set a TaskScheduler is set on each SockJS registration that hasn't had one
|
||||
* registered explicitly. This method needs to be invoked prior to calling
|
||||
* {@link #getHandlerMapping()}.
|
||||
*/
|
||||
protected void setTaskScheduler(TaskScheduler scheduler) {
|
||||
this.scheduler = scheduler;
|
||||
this.registrations.stream()
|
||||
.map(ServletWebSocketHandlerRegistration::getSockJsServiceRegistration)
|
||||
.filter(Objects::nonNull)
|
||||
.filter(r -> r.getTaskScheduler() == null)
|
||||
.forEach(r -> r.setTaskScheduler(scheduler));
|
||||
}
|
||||
|
||||
public AbstractHandlerMapping getHandlerMapping() {
|
||||
Map<String, Object> urlMap = new LinkedHashMap<>();
|
||||
for (ServletWebSocketHandlerRegistration registration : this.registrations) {
|
||||
updateTaskScheduler(registration);
|
||||
MultiValueMap<HttpRequestHandler, String> mappings = registration.getMappings();
|
||||
mappings.forEach((httpHandler, patterns) -> {
|
||||
for (String pattern : patterns) {
|
||||
@@ -142,11 +131,4 @@ public class ServletWebSocketHandlerRegistry implements WebSocketHandlerRegistry
|
||||
return hm;
|
||||
}
|
||||
|
||||
private void updateTaskScheduler(ServletWebSocketHandlerRegistration registration) {
|
||||
SockJsServiceRegistration sockJsRegistration = registration.getSockJsServiceRegistration();
|
||||
if (sockJsRegistration != null && this.scheduler != null && sockJsRegistration.getTaskScheduler() == null) {
|
||||
sockJsRegistration.setTaskScheduler(this.scheduler);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -83,18 +83,6 @@ public class SockJsServiceRegistration {
|
||||
public SockJsServiceRegistration() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated constructor with a TaskScheduler.
|
||||
* @deprecated as of 5.0 a TaskScheduler is not provided upfront, not until
|
||||
* it is obvious that it is needed; call {@link #getTaskScheduler()} to check
|
||||
* and then {@link #setTaskScheduler(TaskScheduler)} to set it before a call
|
||||
* to {@link #createSockJsService()}
|
||||
*/
|
||||
@Deprecated
|
||||
public SockJsServiceRegistration(TaskScheduler defaultTaskScheduler) {
|
||||
this.scheduler = defaultTaskScheduler;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A scheduler instance to use for scheduling SockJS heart-beats.
|
||||
|
||||
Reference in New Issue
Block a user