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 Modifier and Type Class Description static class
ServerWebSocketContainer.SockJsServiceOptions
-
Field Summary
Fields inherited from class org.springframework.integration.websocket.IntegrationWebSocketContainer
DEFAULT_SEND_BUFFER_SIZE, DEFAULT_SEND_TIME_LIMIT, logger, sessions, webSocketHandler
-
Constructor Summary
Constructors Constructor Description ServerWebSocketContainer(String... paths)
-
Method Summary
Modifier and Type Method Description int
getPhase()
boolean
isAutoStartup()
boolean
isRunning()
void
registerWebSocketHandlers(WebSocketHandlerRegistry registry)
ServerWebSocketContainer
setAllowedOrigins(String... origins)
Configure allowedOrigin
header values.void
setAutoStartup(boolean autoStartup)
ServerWebSocketContainer
setDecoratorFactories(WebSocketHandlerDecoratorFactory... factories)
Configure one or more factories to decorate the handler used to process WebSocket messages.ServerWebSocketContainer
setHandshakeHandler(HandshakeHandler handshakeHandler)
ServerWebSocketContainer
setInterceptors(HandshakeInterceptor... interceptors)
void
setPhase(int phase)
void
setSockJsServiceOptions(ServerWebSocketContainer.SockJsServiceOptions sockJsServiceOptions)
void
start()
void
stop()
void
stop(Runnable callback)
ServerWebSocketContainer
withSockJs(ServerWebSocketContainer.SockJsServiceOptions... sockJsServiceOptions)
Methods inherited from class org.springframework.integration.websocket.IntegrationWebSocketContainer
addSupportedProtocols, closeSession, destroy, getSession, getSessions, getSubProtocols, getWebSocketHandler, setMessageListener, setSendBufferSizeLimit, setSendTimeLimit, setSupportedProtocols
-
Constructor Details
-
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:
WebSocketHandlerRegistration.setAllowedOrigins(String...)
-
withSockJs
public ServerWebSocketContainer withSockJs(ServerWebSocketContainer.SockJsServiceOptions... sockJsServiceOptions) -
setSockJsServiceOptions
public void setSockJsServiceOptions(ServerWebSocketContainer.SockJsServiceOptions sockJsServiceOptions) -
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
-