Class ServerWebSocketContainer
java.lang.Object
org.springframework.integration.websocket.IntegrationWebSocketContainer
org.springframework.integration.websocket.ServerWebSocketContainer
- All Implemented Interfaces:
DisposableBean
,Lifecycle
,Phased
,SmartLifecycle
,WebSocketConfigurer
public class ServerWebSocketContainer
extends IntegrationWebSocketContainer
implements WebSocketConfigurer, SmartLifecycle
The
IntegrationWebSocketContainer
implementation for the server
WebSocketHandler
registration.
Registers an internal IntegrationWebSocketContainer.IntegrationWebSocketHandler
for provided paths
with the WebSocketHandlerRegistry
.
The real registration is based on Spring Web-Socket infrastructure via WebSocketConfigurer
implementation of this class.
- Since:
- 4.1
- Author:
- Artem Bilan, Gary Russell
-
Nested Class Summary
-
Field Summary
Fields inherited from class org.springframework.integration.websocket.IntegrationWebSocketContainer
DEFAULT_SEND_BUFFER_SIZE, DEFAULT_SEND_TIME_LIMIT, logger, sessions
Fields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
getPhase()
boolean
boolean
void
setAllowedOrigins
(String... origins) Configure allowedOrigin
header values.void
setAutoStartup
(boolean autoStartup) setDecoratorFactories
(WebSocketHandlerDecoratorFactory... factories) Configure one or more factories to decorate the handler used to process WebSocket messages.setHandshakeHandler
(HandshakeHandler handshakeHandler) setInterceptors
(HandshakeInterceptor... interceptors) void
setPhase
(int phase) void
setSockJsServiceOptions
(ServerWebSocketContainer.SockJsServiceOptions sockJsServiceOptions) void
setSockJsTaskScheduler
(TaskScheduler sockJsTaskScheduler) Configure aTaskScheduler
for SockJS fallback service.void
start()
void
stop()
void
withSockJs
(ServerWebSocketContainer.SockJsServiceOptions... sockJsServiceOptions) Methods inherited from class org.springframework.integration.websocket.IntegrationWebSocketContainer
addSupportedProtocols, closeSession, destroy, getSession, getSessions, getSubProtocols, getWebSocketHandler, setMessageListener, setSendBufferSizeLimit, setSendTimeLimit, setSupportedProtocols, setWebSocketHandler
-
Constructor Details
-
ServerWebSocketContainer
-
-
Method Details
-
setHandshakeHandler
-
setInterceptors
-
setDecoratorFactories
public ServerWebSocketContainer setDecoratorFactories(WebSocketHandlerDecoratorFactory... factories) Configure one or more factories to decorate the handler used to process WebSocket messages. This may be useful in some advanced use cases, for example to allow Spring Security to forcibly close the WebSocket session when the corresponding HTTP session expires.- Parameters:
factories
- the WebSocketHandlerDecoratorFactory array to use- Returns:
- the current ServerWebSocketContainer
- Since:
- 4.2
-
setAllowedOrigins
Configure allowedOrigin
header values.- Parameters:
origins
- the origins to allow.- Returns:
- the current ServerWebSocketContainer
- Since:
- 4.3
- See Also:
-
withSockJs
public ServerWebSocketContainer withSockJs(ServerWebSocketContainer.SockJsServiceOptions... sockJsServiceOptions) -
setSockJsServiceOptions
public void setSockJsServiceOptions(ServerWebSocketContainer.SockJsServiceOptions sockJsServiceOptions) -
setSockJsTaskScheduler
Configure aTaskScheduler
for SockJS fallback service. This is an alternative for default SockJS service scheduler when Websocket endpoint (this server container) is registered at runtime.- Parameters:
sockJsTaskScheduler
- theTaskScheduler
for SockJS fallback service.- Since:
- 5.5.1
-
getSockJsTaskScheduler
-
registerWebSocketHandlers
- Specified by:
registerWebSocketHandlers
in interfaceWebSocketConfigurer
-
setAutoStartup
public void setAutoStartup(boolean autoStartup) -
setPhase
public void setPhase(int phase) -
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartup
in interfaceSmartLifecycle
-
getPhase
public int getPhase()- Specified by:
getPhase
in interfacePhased
- Specified by:
getPhase
in interfaceSmartLifecycle
-
isRunning
public boolean isRunning() -
start
public void start() -
stop
public void stop() -
stop
- Specified by:
stop
in interfaceSmartLifecycle
-