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
Nested Classes -
Field Summary
Fields inherited from class org.springframework.integration.websocket.IntegrationWebSocketContainer
DEFAULT_SEND_BUFFER_SIZE, DEFAULT_SEND_TIME_LIMIT, logger, sessionsFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionintgetPhase()booleanbooleanvoidsetAllowedOrigins(String... origins) Configure allowedOriginheader values.voidsetAutoStartup(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) voidsetPhase(int phase) voidsetSockJsServiceOptions(ServerWebSocketContainer.SockJsServiceOptions sockJsServiceOptions) voidsetSockJsTaskScheduler(TaskScheduler sockJsTaskScheduler) Configure aTaskSchedulerfor SockJS fallback service.voidstart()voidstop()voidwithSockJs(ServerWebSocketContainer.SockJsServiceOptions... sockJsServiceOptions) Methods inherited from class org.springframework.integration.websocket.IntegrationWebSocketContainer
addSupportedProtocols, closeSession, destroy, getSession, getSessions, getSubProtocols, getWebSocketHandler, setMessageListener, setSendBufferOverflowStrategy, 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 allowedOriginheader 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 aTaskSchedulerfor SockJS fallback service. This is an alternative for default SockJS service scheduler when Websocket endpoint (this server container) is registered at runtime.- Parameters:
sockJsTaskScheduler- theTaskSchedulerfor SockJS fallback service.- Since:
- 5.5.1
-
getSockJsTaskScheduler
-
registerWebSocketHandlers
- Specified by:
registerWebSocketHandlersin interfaceWebSocketConfigurer
-
setAutoStartup
public void setAutoStartup(boolean autoStartup) -
setPhase
public void setPhase(int phase) -
isAutoStartup
public boolean isAutoStartup()- Specified by:
isAutoStartupin interfaceSmartLifecycle
-
getPhase
public int getPhase()- Specified by:
getPhasein interfacePhased- Specified by:
getPhasein interfaceSmartLifecycle
-
isRunning
public boolean isRunning() -
start
public void start() -
stop
public void stop() -
stop
- Specified by:
stopin interfaceSmartLifecycle
-