diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandler.java index cd9bb4727f4..747e0925569 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandler.java @@ -44,10 +44,12 @@ public interface TransportHandler { TransportType getTransportType(); /** - * Whether the type of the given session matches the transport type of this - * {@code TransportHandler} where session id and the transport type are - * extracted from the SockJS URL. - * @since 4.3.3 + * Check whether the type of the given session matches the transport type + * of this {@code TransportHandler} where session id and the transport type + * are extracted from the SockJS URL. + * @return {@code true} if the session matches (and would therefore get + * accepted by {@link #handleRequest}), or {@code false} otherwise + * @since 4.3.4 */ boolean checkSessionType(SockJsSession session); diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpReceivingTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpReceivingTransportHandler.java index ef60a60d410..198757d95a6 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpReceivingTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpReceivingTransportHandler.java @@ -38,6 +38,10 @@ import org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJ */ public abstract class AbstractHttpReceivingTransportHandler extends AbstractTransportHandler { + @Override + public boolean checkSessionType(SockJsSession session) { + return (session instanceof AbstractHttpSockJsSession); + } @Override public final void handleRequest(ServerHttpRequest request, ServerHttpResponse response, @@ -95,13 +99,9 @@ public abstract class AbstractHttpReceivingTransportHandler extends AbstractTran } } + protected abstract String[] readMessages(ServerHttpRequest request) throws IOException; protected abstract HttpStatus getResponseStatus(); - @Override - public boolean checkSessionType(SockJsSession session) { - return session instanceof AbstractHttpSockJsSession; - } - } diff --git a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractTransportHandler.java b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractTransportHandler.java index 85388081c9c..bb77b75b0a8 100644 --- a/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractTransportHandler.java +++ b/spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractTransportHandler.java @@ -23,12 +23,14 @@ import org.springframework.web.socket.sockjs.transport.SockJsServiceConfig; import org.springframework.web.socket.sockjs.transport.TransportHandler; /** + * Common base class for {@link TransportHandler} inplementations. + * * @author Rossen Stoyanchev * @since 4.0 */ public abstract class AbstractTransportHandler implements TransportHandler { - protected final Log logger = LogFactory.getLog(this.getClass()); + protected final Log logger = LogFactory.getLog(getClass()); private SockJsServiceConfig serviceConfig;