Polishing (backported from master)
This commit is contained in:
@@ -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 java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import javax.websocket.ClientEndpointConfig;
|
||||
import javax.websocket.ClientEndpointConfig.Configurator;
|
||||
import javax.websocket.ContainerProvider;
|
||||
@@ -51,7 +50,6 @@ import org.springframework.web.socket.adapter.standard.StandardWebSocketSession;
|
||||
import org.springframework.web.socket.adapter.standard.WebSocketToStandardExtensionAdapter;
|
||||
import org.springframework.web.socket.client.AbstractWebSocketClient;
|
||||
|
||||
|
||||
/**
|
||||
* A WebSocketClient based on standard Java WebSocket API.
|
||||
*
|
||||
|
||||
@@ -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.
|
||||
@@ -67,8 +67,8 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
|
||||
org.springframework.messaging.simp.user.UserSessionRegistry userSessionRegistry,
|
||||
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);
|
||||
@@ -87,19 +87,17 @@ public class WebMvcStompEndpointRegistry implements StompEndpointRegistry {
|
||||
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 +142,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.
|
||||
|
||||
@@ -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.
|
||||
@@ -193,7 +193,7 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda
|
||||
|
||||
private static final Method registerMethod;
|
||||
|
||||
private static final Method unRegisterMethod;
|
||||
private static final Method unregisterMethod;
|
||||
|
||||
static {
|
||||
try {
|
||||
@@ -204,7 +204,7 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda
|
||||
throw new IllegalStateException("Expected TyrusEndpointWrapper constructor with 9 or 10 arguments");
|
||||
}
|
||||
registerMethod = TyrusWebSocketEngine.class.getDeclaredMethod("register", TyrusEndpointWrapper.class);
|
||||
unRegisterMethod = TyrusWebSocketEngine.class.getDeclaredMethod("unregister", TyrusEndpointWrapper.class);
|
||||
unregisterMethod = TyrusWebSocketEngine.class.getDeclaredMethod("unregister", TyrusEndpointWrapper.class);
|
||||
ReflectionUtils.makeAccessible(registerMethod);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
@@ -259,7 +259,7 @@ public abstract class AbstractTyrusRequestUpgradeStrategy extends AbstractStanda
|
||||
@Override
|
||||
public void unregister(TyrusWebSocketEngine engine, Object endpoint) {
|
||||
try {
|
||||
unRegisterMethod.invoke(engine, endpoint);
|
||||
unregisterMethod.invoke(engine, endpoint);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
throw new HandshakeFailureException("Failed to unregister " + endpoint, ex);
|
||||
|
||||
@@ -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.
|
||||
@@ -60,7 +60,6 @@ public class WebLogicRequestUpgradeStrategy extends AbstractTyrusRequestUpgradeS
|
||||
private static final WebLogicServletWriterHelper servletWriterHelper = new WebLogicServletWriterHelper();
|
||||
|
||||
private static final Connection.CloseListener noOpCloseListener = new Connection.CloseListener() {
|
||||
|
||||
@Override
|
||||
public void close(CloseReason reason) {
|
||||
}
|
||||
|
||||
@@ -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,6 +54,7 @@ public abstract class AbstractXhrTransport implements XhrTransport {
|
||||
PRELUDE = new String(bytes, SockJsFrame.CHARSET);
|
||||
}
|
||||
|
||||
|
||||
protected Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private boolean xhrStreamingDisabled;
|
||||
@@ -137,6 +138,7 @@ public abstract class AbstractXhrTransport implements XhrTransport {
|
||||
URI receiveUrl, HttpHeaders handshakeHeaders, XhrClientSockJsSession session,
|
||||
SettableListenableFuture<WebSocketSession> connectFuture);
|
||||
|
||||
|
||||
// InfoReceiver methods
|
||||
|
||||
@Override
|
||||
@@ -165,6 +167,7 @@ public abstract class AbstractXhrTransport implements XhrTransport {
|
||||
|
||||
protected abstract ResponseEntity<String> executeInfoRequestInternal(URI infoUrl, HttpHeaders headers);
|
||||
|
||||
|
||||
// XhrTransport methods
|
||||
|
||||
@Override
|
||||
@@ -184,8 +187,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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 1.0 KiB |
Reference in New Issue
Block a user