Class ClientWebSocketContainer

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

public final class ClientWebSocketContainer
extends IntegrationWebSocketContainer
implements org.springframework.context.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
  • Constructor Details

    • ClientWebSocketContainer

      public ClientWebSocketContainer​(org.springframework.web.socket.client.WebSocketClient client, java.lang.String uriTemplate, java.lang.Object... uriVariables)
  • Method Details

    • setOrigin

      public void setOrigin​(java.lang.String origin)
    • setHeadersMap

      public void setHeadersMap​(java.util.Map<java.lang.String,​java.lang.String> headers)
    • setHeaders

      public void setHeaders​(org.springframework.http.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 org.springframework.web.socket.WebSocketSession getSession​(java.lang.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 org.springframework.context.SmartLifecycle
    • getPhase

      public int getPhase()
      Specified by:
      getPhase in interface org.springframework.context.Phased
      Specified by:
      getPhase in interface org.springframework.context.SmartLifecycle
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle
    • start

      public void start()
      Specified by:
      start in interface org.springframework.context.Lifecycle
    • stop

      public void stop()
      Specified by:
      stop in interface org.springframework.context.Lifecycle
    • stop

      public void stop​(java.lang.Runnable callback)
      Specified by:
      stop in interface org.springframework.context.SmartLifecycle