Browse Source

Polishing

Issue: SPR-14867
pull/22835/head
Juergen Hoeller 9 years ago
parent
commit
a90e4b230f
  1. 10
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandler.java
  2. 10
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpReceivingTransportHandler.java
  3. 4
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractTransportHandler.java

10
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandler.java

@ -44,10 +44,12 @@ public interface TransportHandler { @@ -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);

10
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 @@ -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 @@ -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;
}
}

4
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; @@ -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;

Loading…
Cancel
Save