Class JettyWebSocketClient

java.lang.Object
org.springframework.web.socket.client.AbstractWebSocketClient
org.springframework.web.socket.client.jetty.JettyWebSocketClient
All Implemented Interfaces:
org.springframework.context.Lifecycle, WebSocketClient

@Deprecated(since="6.0.3", forRemoval=true) public class JettyWebSocketClient extends AbstractWebSocketClient implements org.springframework.context.Lifecycle
Deprecated, for removal: This API element is subject to removal in a future version.
as of 6.0.3, in favor of StandardWebSocketClient
Initiates WebSocket requests to a WebSocket server programmatically through the Jetty WebSocket API. Only supported on Jetty 11, superseded by StandardWebSocketClient.

As of 4.1 this class implements Lifecycle rather than SmartLifecycle. Use WebSocketConnectionManager instead to auto-start a WebSocket connection.

Since:
4.0
Author:
Rossen Stoyanchev, Juergen Hoeller
  • Field Summary

    Fields inherited from class org.springframework.web.socket.client.AbstractWebSocketClient

    logger
  • Constructor Summary

    Constructors
    Constructor
    Description
    Deprecated, for removal: This API element is subject to removal in a future version.
    Default constructor that creates an instance of WebSocketClient.
    JettyWebSocketClient(org.eclipse.jetty.websocket.client.WebSocketClient client)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Constructor that accepts an existing WebSocketClient instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    executeInternal(WebSocketHandler wsHandler, org.springframework.http.HttpHeaders headers, URI uri, List<String> protocols, List<WebSocketExtension> extensions, Map<String,Object> attributes)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Perform the actual handshake to establish a connection to the server.
    org.springframework.core.task.AsyncTaskExecutor
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the configured AsyncTaskExecutor.
    protected Principal
    Deprecated, for removal: This API element is subject to removal in a future version.
    Return the user to make available through WebSocketSession.getPrincipal().
    boolean
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    void
    setTaskExecutor(org.springframework.core.task.AsyncTaskExecutor taskExecutor)
    Deprecated, for removal: This API element is subject to removal in a future version.
    Set an AsyncTaskExecutor to use when opening connections.
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
     
    void
    Deprecated, for removal: This API element is subject to removal in a future version.
     

    Methods inherited from class org.springframework.web.socket.client.AbstractWebSocketClient

    assertUri, doHandshakeInternal, execute, execute

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.web.socket.client.WebSocketClient

    doHandshake, doHandshake
  • Constructor Details

    • JettyWebSocketClient

      public JettyWebSocketClient()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Default constructor that creates an instance of WebSocketClient.
    • JettyWebSocketClient

      public JettyWebSocketClient(org.eclipse.jetty.websocket.client.WebSocketClient client)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Constructor that accepts an existing WebSocketClient instance.
  • Method Details

    • setTaskExecutor

      public void setTaskExecutor(@Nullable org.springframework.core.task.AsyncTaskExecutor taskExecutor)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Set an AsyncTaskExecutor to use when opening connections.

      If this property is set to null, calls to any of the doHandshake methods will block until the connection is established.

      By default an instance of SimpleAsyncTaskExecutor is used.

    • getTaskExecutor

      @Nullable public org.springframework.core.task.AsyncTaskExecutor getTaskExecutor()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the configured AsyncTaskExecutor.
    • start

      public void start()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      start in interface org.springframework.context.Lifecycle
    • stop

      public void stop()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      stop in interface org.springframework.context.Lifecycle
    • isRunning

      public boolean isRunning()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle
    • executeInternal

      public CompletableFuture<WebSocketSession> executeInternal(WebSocketHandler wsHandler, org.springframework.http.HttpHeaders headers, URI uri, List<String> protocols, List<WebSocketExtension> extensions, Map<String,Object> attributes)
      Deprecated, for removal: This API element is subject to removal in a future version.
      Description copied from class: AbstractWebSocketClient
      Perform the actual handshake to establish a connection to the server.
      Specified by:
      executeInternal in class AbstractWebSocketClient
      Parameters:
      wsHandler - the client-side handler for WebSocket messages
      headers - the HTTP headers to use for the handshake, with unwanted (forbidden) headers filtered out (never null)
      uri - the target URI for the handshake (never null)
      protocols - requested sub-protocols, or an empty list
      extensions - requested WebSocket extensions, or an empty list
      attributes - the attributes to associate with the WebSocketSession, i.e. via WebSocketSession.getAttributes(); currently always an empty map
      Returns:
      the established WebSocket session wrapped in a CompletableFuture.
    • getUser

      @Nullable protected Principal getUser()
      Deprecated, for removal: This API element is subject to removal in a future version.
      Return the user to make available through WebSocketSession.getPrincipal(). By default, this method returns null