Polishing

Issue: SPR-14867
(cherry picked from commit a90e4b2)
This commit is contained in:
Juergen Hoeller
2016-11-03 14:41:41 +01:00
parent 9e67ba83a5
commit 05547979de
3 changed files with 16 additions and 13 deletions

View File

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

View File

@@ -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
*/
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
}
}
protected abstract String[] readMessages(ServerHttpRequest request) throws IOException;
protected abstract HttpStatus getResponseStatus();
@Override
public boolean checkSessionType(SockJsSession session) {
return session instanceof AbstractHttpSockJsSession;
}
}

View File

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