Browse Source

Polishing

Issue: SPR-14867
(cherry picked from commit a90e4b2)
pull/1257/head
Juergen Hoeller 9 years ago
parent
commit
05547979de
  1. 10
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/TransportHandler.java
  2. 12
      spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpReceivingTransportHandler.java
  3. 7
      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);

12
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractHttpReceivingTransportHandler.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 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.
@ -37,6 +37,10 @@ import org.springframework.web.socket.sockjs.transport.session.AbstractHttpSockJ @@ -37,6 +37,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,
@ -94,13 +98,9 @@ public abstract class AbstractHttpReceivingTransportHandler extends AbstractTran @@ -94,13 +98,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;
}
}

7
spring-websocket/src/main/java/org/springframework/web/socket/sockjs/transport/handler/AbstractTransportHandler.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 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.
@ -25,6 +25,8 @@ import org.springframework.web.socket.sockjs.transport.SockJsServiceConfig; @@ -25,6 +25,8 @@ 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
*/
@ -32,8 +34,7 @@ public abstract class AbstractTransportHandler implements TransportHandler { @@ -32,8 +34,7 @@ public abstract class AbstractTransportHandler implements TransportHandler {
protected static final Charset UTF8_CHARSET = Charset.forName("UTF-8");
protected final Log logger = LogFactory.getLog(this.getClass());
protected final Log logger = LogFactory.getLog(getClass());
private SockJsServiceConfig serviceConfig;

Loading…
Cancel
Save