Broadly remove deprecated core classes and methods

Issue: SPR-14430
This commit is contained in:
Juergen Hoeller
2016-07-05 15:52:48 +02:00
parent 0fc0ce78ae
commit b5db5d3aac
119 changed files with 145 additions and 6086 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -61,14 +61,11 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
new ArrayList<WebMvcStompWebSocketEndpointRegistration>();
@SuppressWarnings("deprecation")
public WebMvcStompEndpointRegistry(WebSocketHandler webSocketHandler,
WebSocketTransportRegistration transportRegistration,
org.springframework.messaging.simp.user.UserSessionRegistry userSessionRegistry,
TaskScheduler defaultSockJsTaskScheduler) {
WebSocketTransportRegistration transportRegistration, TaskScheduler defaultSockJsTaskScheduler) {
Assert.notNull(webSocketHandler, "'webSocketHandler' is required ");
Assert.notNull(transportRegistration, "'transportRegistration' is required");
Assert.notNull(webSocketHandler, "WebSocketHandler is required ");
Assert.notNull(transportRegistration, "WebSocketTransportRegistration is required");
this.webSocketHandler = webSocketHandler;
this.subProtocolWebSocketHandler = unwrapSubProtocolWebSocketHandler(webSocketHandler);
@@ -81,25 +78,22 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
}
this.stompHandler = new StompSubProtocolHandler();
this.stompHandler.setUserSessionRegistry(userSessionRegistry);
if (transportRegistration.getMessageSizeLimit() != null) {
this.stompHandler.setMessageSizeLimit(transportRegistration.getMessageSizeLimit());
}
this.sockJsScheduler = defaultSockJsTaskScheduler;
}
private static SubProtocolWebSocketHandler unwrapSubProtocolWebSocketHandler(WebSocketHandler handler) {
WebSocketHandler actual = WebSocketHandlerDecorator.unwrap(handler);
Assert.isInstanceOf(SubProtocolWebSocketHandler.class, actual, "No SubProtocolWebSocketHandler in " + handler);
if (!(actual instanceof SubProtocolWebSocketHandler)) {
throw new IllegalArgumentException("No SubProtocolWebSocketHandler in " + handler);
};
return (SubProtocolWebSocketHandler) actual;
}
protected void setApplicationContext(ApplicationContext applicationContext) {
this.stompHandler.setApplicationEventPublisher(applicationContext);
}
@Override
public StompWebSocketEndpointRegistration addEndpoint(String... paths) {
@@ -144,6 +138,11 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
return this;
}
protected void setApplicationContext(ApplicationContext applicationContext) {
this.stompHandler.setApplicationEventPublisher(applicationContext);
}
/**
* Return a handler mapping with the mapped ViewControllers; or {@code null}
* in case of no registrations.

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -26,7 +26,6 @@ import org.springframework.messaging.simp.broker.AbstractBrokerMessageHandler;
import org.springframework.messaging.simp.config.AbstractMessageBrokerConfiguration;
import org.springframework.messaging.simp.stomp.StompBrokerRelayMessageHandler;
import org.springframework.messaging.simp.user.SimpUserRegistry;
import org.springframework.messaging.simp.user.UserSessionRegistryAdapter;
import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.config.WebSocketMessageBrokerStats;
@@ -59,21 +58,15 @@ public abstract class WebSocketMessageBrokerConfigurationSupport extends Abstrac
}
@Override
@SuppressWarnings("deprecation")
protected SimpUserRegistry createLocalUserRegistry() {
org.springframework.messaging.simp.user.UserSessionRegistry sessionRegistry = userSessionRegistry();
if (sessionRegistry != null) {
return new UserSessionRegistryAdapter(sessionRegistry);
}
return new DefaultSimpUserRegistry();
}
@Bean
@SuppressWarnings("deprecation")
public HandlerMapping stompWebSocketHandlerMapping() {
WebSocketHandler handler = decorateWebSocketHandler(subProtocolWebSocketHandler());
WebMvcStompEndpointRegistry registry = new WebMvcStompEndpointRegistry(handler,
getTransportRegistration(), userSessionRegistry(), messageBrokerTaskScheduler());
getTransportRegistration(), messageBrokerTaskScheduler());
registry.setApplicationContext(getApplicationContext());
registerStompEndpoints(registry);
return registry.getHandlerMapping();

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -94,9 +94,6 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
private int messageSizeLimit = 64 * 1024;
@SuppressWarnings("deprecation")
private org.springframework.messaging.simp.user.UserSessionRegistry userSessionRegistry;
private final StompEncoder stompEncoder = new StompEncoder();
private final StompDecoder stompDecoder = new StompDecoder();
@@ -150,27 +147,6 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
return this.messageSizeLimit;
}
/**
* Provide a registry with which to register active user session ids.
* @see org.springframework.messaging.simp.user.UserDestinationMessageHandler
* @deprecated as of 4.2 in favor of {@link DefaultSimpUserRegistry} which relies
* on the ApplicationContext events published by this class and is created via
* {@link org.springframework.web.socket.config.annotation.WebSocketMessageBrokerConfigurationSupport#createLocalUserRegistry
* WebSocketMessageBrokerConfigurationSupport.createLocalUserRegistry}
*/
@Deprecated
public void setUserSessionRegistry(org.springframework.messaging.simp.user.UserSessionRegistry registry) {
this.userSessionRegistry = registry;
}
/**
* @deprecated as of 4.2
*/
@Deprecated
public org.springframework.messaging.simp.user.UserSessionRegistry getUserSessionRegistry() {
return this.userSessionRegistry;
}
/**
* Configure a {@link MessageHeaderInitializer} to apply to the headers of all
* messages created from decoded STOMP frames and other messages sent to the
@@ -303,7 +279,6 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
}
}
@SuppressWarnings("deprecation")
private void handleError(WebSocketSession session, Throwable ex, Message<byte[]> clientMessage) {
if (getErrorHandler() == null) {
sendErrorMessage(session, ex);
@@ -324,12 +299,8 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
* Invoked when no
* {@link #setErrorHandler(StompSubProtocolErrorHandler) errorHandler}
* is configured to send an ERROR frame to the client.
* @deprecated as of Spring 4.2, in favor of
* {@link #setErrorHandler(StompSubProtocolErrorHandler) configuring}
* a {@code StompSubProtocolErrorHandler}
*/
@Deprecated
protected void sendErrorMessage(WebSocketSession session, Throwable error) {
private void sendErrorMessage(WebSocketSession session, Throwable error) {
StompHeaderAccessor headerAccessor = StompHeaderAccessor.create(StompCommand.ERROR);
headerAccessor.setMessage(error.getMessage());
@@ -527,7 +498,6 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
return (headerAccessor.isMutable() ? headerAccessor : StompHeaderAccessor.wrap(message));
}
@SuppressWarnings("deprecation")
private StompHeaderAccessor afterStompSessionConnected(Message<?> message, StompHeaderAccessor accessor,
WebSocketSession session) {
@@ -535,10 +505,6 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
if (principal != null) {
accessor = toMutableAccessor(accessor, message);
accessor.setNativeHeader(CONNECTED_USER_HEADER, principal.getName());
if (this.userSessionRegistry != null) {
String userName = getSessionRegistryUserName(principal);
this.userSessionRegistry.registerSessionId(userName, session.getId());
}
}
long[] heartbeat = accessor.getHeartbeat();
@@ -552,14 +518,6 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
return accessor;
}
private String getSessionRegistryUserName(Principal principal) {
String userName = principal.getName();
if (principal instanceof DestinationUserNameProvider) {
userName = ((DestinationUserNameProvider) principal).getDestinationUserName();
}
return userName;
}
@Override
public String resolveSessionId(Message<?> message) {
return SimpMessageHeaderAccessor.getSessionId(message.getHeaders());
@@ -574,16 +532,9 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
}
@Override
@SuppressWarnings("deprecation")
public void afterSessionEnded(WebSocketSession session, CloseStatus closeStatus, MessageChannel outputChannel) {
this.decoders.remove(session.getId());
Principal principal = session.getPrincipal();
if (principal != null && this.userSessionRegistry != null) {
String userName = getSessionRegistryUserName(principal);
this.userSessionRegistry.unregisterSessionId(userName, session.getId());
}
Message<byte[]> message = createDisconnectMessage(session);
SimpAttributes simpAttributes = SimpAttributes.fromMessage(message);
try {

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -54,12 +54,11 @@ public abstract class AbstractXhrTransport implements XhrTransport {
PRELUDE = new String(bytes, SockJsFrame.CHARSET);
}
protected Log logger = LogFactory.getLog(getClass());
private boolean xhrStreamingDisabled;
private HttpHeaders requestHeaders = new HttpHeaders();
@Override
public List<TransportType> getTransportTypes() {
@@ -91,29 +90,10 @@ public abstract class AbstractXhrTransport implements XhrTransport {
return this.xhrStreamingDisabled;
}
/**
* Configure headers to be added to every executed HTTP request.
* @param requestHeaders the headers to add to requests
* @deprecated as of 4.2 in favor of {@link SockJsClient#setHttpHeaderNames}.
*/
@Deprecated
public void setRequestHeaders(HttpHeaders requestHeaders) {
this.requestHeaders.clear();
if (requestHeaders != null) {
this.requestHeaders.putAll(requestHeaders);
}
}
@Deprecated
public HttpHeaders getRequestHeaders() {
return this.requestHeaders;
}
// Transport methods
@Override
@SuppressWarnings("deprecation")
public ListenableFuture<WebSocketSession> connect(TransportRequest request, WebSocketHandler handler) {
SettableListenableFuture<WebSocketSession> connectFuture = new SettableListenableFuture<WebSocketSession>();
XhrClientSockJsSession session = new XhrClientSockJsSession(request, handler, this, connectFuture);
@@ -126,7 +106,6 @@ public abstract class AbstractXhrTransport implements XhrTransport {
}
HttpHeaders handshakeHeaders = new HttpHeaders();
handshakeHeaders.putAll(getRequestHeaders());
handshakeHeaders.putAll(request.getHandshakeHeaders());
connectInternal(request, handler, receiveUrl, handshakeHeaders, session, connectFuture);
@@ -137,16 +116,15 @@ public abstract class AbstractXhrTransport implements XhrTransport {
URI receiveUrl, HttpHeaders handshakeHeaders, XhrClientSockJsSession session,
SettableListenableFuture<WebSocketSession> connectFuture);
// InfoReceiver methods
@Override
@SuppressWarnings("deprecation")
public String executeInfoRequest(URI infoUrl, HttpHeaders headers) {
if (logger.isDebugEnabled()) {
logger.debug("Executing SockJS Info request, url=" + infoUrl);
}
HttpHeaders infoRequestHeaders = new HttpHeaders();
infoRequestHeaders.putAll(getRequestHeaders());
if (headers != null) {
infoRequestHeaders.putAll(headers);
}
@@ -184,8 +162,8 @@ public abstract class AbstractXhrTransport implements XhrTransport {
}
}
protected abstract ResponseEntity<String> executeSendRequestInternal(URI url,
HttpHeaders headers, TextMessage message);
protected abstract ResponseEntity<String> executeSendRequestInternal(
URI url, HttpHeaders headers, TextMessage message);
@Override

View File

@@ -171,12 +171,6 @@ public abstract class AbstractHttpSockJsSession extends AbstractSockJsSession {
return Collections.emptyList();
}
/**
* @deprecated as of 4.2, since this method is no longer used.
*/
@Deprecated
protected abstract boolean isStreaming();
/**
* Handle the first request for receiving messages on a SockJS HTTP transport
@@ -317,14 +311,6 @@ public abstract class AbstractHttpSockJsSession extends AbstractSockJsSession {
protected abstract void flushCache() throws SockJsTransportFailureException;
/**
* @deprecated as of 4.2 this method is deprecated since the prelude is written
* in {@link #handleRequestInternal} of the StreamingSockJsSession subclass.
*/
@Deprecated
protected void writePrelude(ServerHttpRequest request, ServerHttpResponse response) throws IOException {
}
@Override
protected void disconnect(CloseStatus status) {
resetRequest();

View File

@@ -35,7 +35,6 @@ import org.springframework.web.socket.sockjs.transport.SockJsServiceConfig;
*/
public class PollingSockJsSession extends AbstractHttpSockJsSession {
public PollingSockJsSession(String sessionId, SockJsServiceConfig config,
WebSocketHandler wsHandler, Map<String, Object> attributes) {
@@ -43,15 +42,6 @@ public class PollingSockJsSession extends AbstractHttpSockJsSession {
}
/**
* @deprecated as of 4.2 this method is no longer used.
*/
@Override
@Deprecated
protected boolean isStreaming() {
return false;
}
@Override
protected void handleRequestInternal(ServerHttpRequest request, ServerHttpResponse response,
boolean initialRequest) throws IOException {
@@ -85,4 +75,3 @@ public class PollingSockJsSession extends AbstractHttpSockJsSession {
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -46,15 +46,6 @@ public abstract class StreamingSockJsSession extends AbstractHttpSockJsSession {
}
/**
* @deprecated as of 4.2, since this method is no longer used.
*/
@Override
@Deprecated
protected boolean isStreaming() {
return true;
}
/**
* Get the prelude to write to the response before any other data.
* @since 4.2

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -54,7 +54,7 @@ public class WebMvcStompEndpointRegistryTests {
WebSocketTransportRegistration transport = new WebSocketTransportRegistration();
TaskScheduler scheduler = mock(TaskScheduler.class);
this.endpointRegistry = new WebMvcStompEndpointRegistry(this.webSocketHandler, transport, null, scheduler);
this.endpointRegistry = new WebMvcStompEndpointRegistry(this.webSocketHandler, transport, scheduler);
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2015 the original author or authors.
* Copyright 2002-2016 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.
@@ -78,7 +78,6 @@ public class XhrTransportTests {
transport.executeSendRequest(url, null, new TextMessage("payload"));
}
@SuppressWarnings("deprecation")
@Test
public void connect() throws Exception {
HttpHeaders handshakeHeaders = new HttpHeaders();
@@ -88,12 +87,7 @@ public class XhrTransportTests {
given(request.getSockJsUrlInfo()).willReturn(new SockJsUrlInfo(new URI("http://example.com")));
given(request.getHandshakeHeaders()).willReturn(handshakeHeaders);
HttpHeaders requestHeaders = new HttpHeaders();
requestHeaders.set("foo", "bar");
TestXhrTransport transport = new TestXhrTransport();
transport.setRequestHeaders(requestHeaders);
WebSocketHandler handler = mock(WebSocketHandler.class);
transport.connect(request, handler);
@@ -105,9 +99,8 @@ public class XhrTransportTests {
verify(request).getHttpRequestHeaders();
verifyNoMoreInteractions(request);
assertEquals(2, transport.actualHandshakeHeaders.size());
assertEquals(1, transport.actualHandshakeHeaders.size());
assertEquals("foo", transport.actualHandshakeHeaders.getOrigin());
assertEquals("bar", transport.actualHandshakeHeaders.getFirst("foo"));
assertFalse(transport.actualSession.isDisconnected());
captor.getValue().run();