Class ClientWebSocketContainer

java.lang.Object
org.springframework.integration.websocket.IntegrationWebSocketContainer
org.springframework.integration.websocket.ClientWebSocketContainer
All Implemented Interfaces:
DisposableBean, Lifecycle, Phased, SmartLifecycle

public final class ClientWebSocketContainer extends IntegrationWebSocketContainer implements SmartLifecycle
The IntegrationWebSocketContainer implementation for the client Web-Socket connection.

Represent the composition over an internal ConnectionManagerSupport implementation.

Accepts the clientSession WebSocketSession on ConnectionManagerSupport.openConnection() event, which can be accessed from this container using getSession(String).

Since:
4.1
Author:
Artem Bilan, Gary Russell, Christian Tzolov
  • Constructor Details

    • ClientWebSocketContainer

      public ClientWebSocketContainer(WebSocketClient client, String uriTemplate, Object... uriVariables)
    • ClientWebSocketContainer

      public ClientWebSocketContainer(WebSocketClient client, URI uri)
      Constructor with a prepared URI.
      Parameters:
      client - the WebSocketClient to use.
      uri - the url to connect to
      Since:
      6.1
  • Method Details

    • setOrigin

      public void setOrigin(String origin)
    • setHeadersMap

      public void setHeadersMap(Map<String,String> headers)
    • setHeaders

      public void setHeaders(HttpHeaders headers)
    • setConnectionTimeout

      public void setConnectionTimeout(int connectionTimeout)
      Set the connection timeout in seconds; default: 10.
      Parameters:
      connectionTimeout - the timeout in seconds.
      Since:
      4.2
    • getSession

      public WebSocketSession getSession(String sessionId)
      Return the clientSession WebSocketSession. Independently of provided argument, this method always returns only the established clientSession
      Overrides:
      getSession in class IntegrationWebSocketContainer
      Parameters:
      sessionId - the sessionId. Can be null.
      Returns:
      the clientSession, if established.
    • setAutoStartup

      public void setAutoStartup(boolean autoStartup)
    • setPhase

      public void setPhase(int phase)
    • isConnected

      public boolean isConnected()
      Return true if the clientSession is opened.
      Returns:
      the WebSocketSession.isOpen() state.
      Since:
      4.2.6
    • isAutoStartup

      public boolean isAutoStartup()
      Specified by:
      isAutoStartup in interface SmartLifecycle
    • getPhase

      public int getPhase()
      Specified by:
      getPhase in interface Phased
      Specified by:
      getPhase in interface SmartLifecycle
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface Lifecycle
    • start

      public void start()
      Specified by:
      start in interface Lifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface Lifecycle
    • stop

      public void stop(Runnable callback)
      Specified by:
      stop in interface SmartLifecycle