public class TransportHandlingSockJsService extends AbstractSockJsService implements SockJsServiceConfig, Lifecycle
SockJsService
with support for SPI-based transport handling and session management.
Based on the TransportHandler SPI. TransportHandlers may additionally
implement the SockJsSessionFactory and HandshakeHandler interfaces.
See the AbstractSockJsService base class for important details on request mapping.
allowedOrigins, logger| Constructor and Description |
|---|
TransportHandlingSockJsService(TaskScheduler scheduler,
java.util.Collection<TransportHandler> handlers)
Create a TransportHandlingSockJsService with given
handler types. |
TransportHandlingSockJsService(TaskScheduler scheduler,
TransportHandler... handlers)
Create a TransportHandlingSockJsService with given
handler types. |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<HandshakeInterceptor> |
getHandshakeInterceptors()
Return the configured WebSocket handshake request interceptors.
|
SockJsMessageCodec |
getMessageCodec()
The codec to use for encoding and decoding SockJS messages.
|
java.util.Map<TransportType,TransportHandler> |
getTransportHandlers()
Return the registered handlers per transport type.
|
protected void |
handleRawWebSocketRequest(ServerHttpRequest request,
ServerHttpResponse response,
WebSocketHandler handler)
Handle request for raw WebSocket communication, i.e.
|
protected void |
handleTransportRequest(ServerHttpRequest request,
ServerHttpResponse response,
WebSocketHandler handler,
java.lang.String sessionId,
java.lang.String transport)
Handle a SockJS session URL (i.e.
|
boolean |
isRunning()
Check whether this component is currently running.
|
void |
setHandshakeInterceptors(java.util.List<HandshakeInterceptor> interceptors)
Configure one or more WebSocket handshake request interceptors.
|
void |
setMessageCodec(SockJsMessageCodec messageCodec)
The codec to use for encoding and decoding SockJS messages.
|
void |
start()
Start this component.
|
void |
stop()
Stop this component, typically in a synchronous fashion, such that the component is
fully stopped upon return of this method.
|
protected boolean |
validateRequest(java.lang.String serverId,
java.lang.String sessionId,
java.lang.String transport) |
addCacheHeaders, addNoCacheHeaders, checkOrigin, getAllowedOrigins, getCorsConfiguration, getDisconnectDelay, getHeartbeatTime, getHttpMessageCacheSize, getName, getSockJsClientLibraryUrl, getStreamBytesLimit, getTaskScheduler, handleRequest, isSessionCookieNeeded, isWebSocketEnabled, sendMethodNotAllowed, setAllowedOrigins, setDisconnectDelay, setHeartbeatTime, setHttpMessageCacheSize, setName, setSessionCookieNeeded, setSockJsClientLibraryUrl, setStreamBytesLimit, setSuppressCors, setWebSocketEnabled, shouldSuppressCorsclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetHeartbeatTime, getHttpMessageCacheSize, getStreamBytesLimit, getTaskSchedulerpublic TransportHandlingSockJsService(TaskScheduler scheduler, TransportHandler... handlers)
handler types.scheduler - a task scheduler for heart-beat messages and removing timed-out sessions;
the provided TaskScheduler should be declared as a Spring bean to ensure it gets
initialized at start-up and shuts down when the application stopshandlers - one or more TransportHandler implementations to usepublic TransportHandlingSockJsService(TaskScheduler scheduler, java.util.Collection<TransportHandler> handlers)
handler types.scheduler - a task scheduler for heart-beat messages and removing timed-out sessions;
the provided TaskScheduler should be declared as a Spring bean to ensure it gets
initialized at start-up and shuts down when the application stopshandlers - one or more TransportHandler implementations to usepublic java.util.Map<TransportType,TransportHandler> getTransportHandlers()
public void setMessageCodec(SockJsMessageCodec messageCodec)
public SockJsMessageCodec getMessageCodec()
SockJsServiceConfiggetMessageCodec in interface SockJsServiceConfigpublic void setHandshakeInterceptors(@Nullable java.util.List<HandshakeInterceptor> interceptors)
public java.util.List<HandshakeInterceptor> getHandshakeInterceptors()
public void start()
LifecycleShould not throw an exception if the component is already running.
In the case of a container, this will propagate the start signal to all components that apply.
start in interface LifecycleSmartLifecycle.isAutoStartup()public void stop()
LifecycleSmartLifecycle
and its stop(Runnable) variant when asynchronous stop behavior is necessary.
Note that this stop notification is not guaranteed to come before destruction: On
regular shutdown, Lifecycle beans will first receive a stop notification before
the general destruction callbacks are being propagated; however, on hot refresh during a
context's lifetime or on aborted refresh attempts, only destroy methods will be called.
Should not throw an exception if the component isn't started yet.
In the case of a container, this will propagate the stop signal to all components that apply.
stop in interface LifecycleSmartLifecycle.stop(Runnable),
DisposableBean.destroy()public boolean isRunning()
LifecycleIn the case of a container, this will return true only if all
components that apply are currently running.
protected void handleRawWebSocketRequest(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler) throws java.io.IOException
AbstractSockJsServicehandleRawWebSocketRequest in class AbstractSockJsServicejava.io.IOExceptionprotected void handleTransportRequest(ServerHttpRequest request, ServerHttpResponse response, WebSocketHandler handler, java.lang.String sessionId, java.lang.String transport) throws SockJsException
AbstractSockJsServicehandleTransportRequest in class AbstractSockJsServiceSockJsExceptionprotected boolean validateRequest(java.lang.String serverId,
java.lang.String sessionId,
java.lang.String transport)
validateRequest in class AbstractSockJsService