org.springframework.web.socket.client.jetty

Class JettyWebSocketClient

    • Constructor Detail

      • JettyWebSocketClient

        public JettyWebSocketClient()
        Default constructor that creates an instance of WebSocketClient.
      • JettyWebSocketClient

        public JettyWebSocketClient(org.eclipse.jetty.websocket.client.WebSocketClient client)
        Constructor that accepts an existing WebSocketClient instance.
    • Method Detail

      • setTaskExecutor

        public void setTaskExecutor(@Nullable
                                    AsyncListenableTaskExecutor taskExecutor)
        Set an AsyncListenableTaskExecutor 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.

      • start

        public void start()
        Description copied from interface: Lifecycle
        Start this component.

        Should not throw an exception if the component is already running.

        In the case of a container, this will propagate the start signal to all components that apply.

        Specified by:
        start in interface Lifecycle
        See Also:
        SmartLifecycle.isAutoStartup()
      • stop

        public void stop()
        Description copied from interface: Lifecycle
        Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method. Consider implementing SmartLifecycle and its stop(Runnable) variant when asynchronous stop behavior is necessary.

        Note that this stop notification is not guaranteed to come before destruction: On regular shutdown, Lifecycle beans will first receive a stop notification before the general destruction callbacks are being propagated; however, on hot refresh during a context's lifetime or on aborted refresh attempts, a given bean's destroy method will be called without any consideration of stop signals upfront.

        Should not throw an exception if the component is not running (not started yet).

        In the case of a container, this will propagate the stop signal to all components that apply.

        Specified by:
        stop in interface Lifecycle
        See Also:
        SmartLifecycle.stop(Runnable), DisposableBean.destroy()
      • isRunning

        public boolean isRunning()
        Description copied from interface: Lifecycle
        Check whether this component is currently running.

        In the case of a container, this will return true only if all components that apply are currently running.

        Specified by:
        isRunning in interface Lifecycle
        Returns:
        whether the component is currently running
      • doHandshakeInternal

        public ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler wsHandler,
                                                                      HttpHeaders headers,
                                                                      java.net.URI uri,
                                                                      java.util.List<java.lang.String> protocols,
                                                                      java.util.List<WebSocketExtension> extensions,
                                                                      java.util.Map<java.lang.String,java.lang.Object> attributes)
        Description copied from class: AbstractWebSocketClient
        Perform the actual handshake to establish a connection to the server.
        Specified by:
        doHandshakeInternal 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 - attributes to associate with the WebSocketSession, i.e. via WebSocketSession.getAttributes(); currently always an empty map.
        Returns:
        the established WebSocket session wrapped in a ListenableFuture.