diff --git a/build.gradle b/build.gradle index 74651bd3277..9b58dc4f9f7 100644 --- a/build.gradle +++ b/build.gradle @@ -505,6 +505,7 @@ project("spring-websocket") { compile(project(":spring-core")) compile(project(":spring-context")) compile(project(":spring-web")) + optional(project(":spring-webmvc")) optional("javax.servlet:javax.servlet-api:3.1.0") optional("javax.websocket:javax.websocket-api:1.0") optional("org.apache.tomcat:tomcat-websocket:8.0-SNAPSHOT") { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java index e5d86e937a0..996d2dece23 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/server/support/WebSocketHttpRequestHandler.java @@ -49,7 +49,7 @@ import org.springframework.web.socket.support.LoggingWebSocketHandlerDecorator; * {@link HttpServletResponse} to {@link ServerHttpRequest} and {@link ServerHttpResponse} * respectively. * - *
The {@link #decorateWebSocketHandler(WebSocketHandler)} method decorates the given + *
The {@link #applyDefaultDecorators(WebSocketHandler)} method decorates the given * WebSocketHandler with a logging and exception handling decorators. This method can * be overridden to change that. * @@ -69,10 +69,10 @@ public class WebSocketHttpRequestHandler implements HttpRequestHandler { this(webSocketHandler, new DefaultHandshakeHandler()); } - public WebSocketHttpRequestHandler( WebSocketHandler webSocketHandler, HandshakeHandler handshakeHandler) { - Assert.notNull(webSocketHandler, "webSocketHandler must not be null"); + public WebSocketHttpRequestHandler(WebSocketHandler wsHandler, HandshakeHandler handshakeHandler) { + Assert.notNull(wsHandler, "wsHandler must not be null"); Assert.notNull(handshakeHandler, "handshakeHandler must not be null"); - this.wsHandler = decorateWebSocketHandler(webSocketHandler); + this.wsHandler = new ExceptionWebSocketHandlerDecorator(new LoggingWebSocketHandlerDecorator(wsHandler)); this.handshakeHandler = handshakeHandler; } @@ -94,17 +94,6 @@ public class WebSocketHttpRequestHandler implements HttpRequestHandler { return this.interceptors; } - /** - * Decorate the WebSocketHandler provided to the class constructor. - * - *
By default {@link ExceptionWebSocketHandlerDecorator} and - * {@link LoggingWebSocketHandlerDecorator} are applied are added. - */ - protected WebSocketHandler decorateWebSocketHandler(WebSocketHandler wsHandler) { - wsHandler = new ExceptionWebSocketHandlerDecorator(wsHandler); - return new LoggingWebSocketHandlerDecorator(wsHandler); - } - @Override public void handleRequest(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException { diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/SockJsHttpRequestHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/SockJsHttpRequestHandler.java index 495989aa0f0..d829a14a89d 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/SockJsHttpRequestHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/SockJsHttpRequestHandler.java @@ -55,21 +55,10 @@ public class SockJsHttpRequestHandler implements HttpRequestHandler { Assert.notNull(sockJsService, "sockJsService must not be null"); Assert.notNull(wsHandler, "webSocketHandler must not be null"); this.sockJsService = sockJsService; - this.wsHandler = decorateWebSocketHandler(wsHandler); + this.wsHandler = new ExceptionWebSocketHandlerDecorator(new LoggingWebSocketHandlerDecorator(wsHandler)); } - /** - * Decorate the WebSocketHandler provided to the class constructor. - * - *
By default {@link ExceptionWebSocketHandlerDecorator} and - * {@link LoggingWebSocketHandlerDecorator} are applied are added. - */ - protected WebSocketHandler decorateWebSocketHandler(WebSocketHandler wsHandler) { - wsHandler = new ExceptionWebSocketHandlerDecorator(wsHandler); - return new LoggingWebSocketHandlerDecorator(wsHandler); - } - @Override public void handleRequest(HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws ServletException, IOException {