public class JettyWebSocketClient extends AbstractWebSocketClient implements SmartLifecycle
logger| Constructor and Description |
|---|
JettyWebSocketClient()
Default constructor that creates an instance of
WebSocketClient. |
JettyWebSocketClient(org.eclipse.jetty.websocket.client.WebSocketClient client)
Constructor that accepts an existing
WebSocketClient instance. |
| Modifier and Type | Method and Description |
|---|---|
ListenableFuture<WebSocketSession> |
doHandshake(WebSocketHandler webSocketHandler,
String uriTemplate,
Object... uriVars) |
ListenableFuture<WebSocketSession> |
doHandshakeInternal(WebSocketHandler wsHandler,
HttpHeaders headers,
URI uri,
List<String> protocols,
List<WebSocketExtension> extensions,
Map<String,Object> attributes)
Perform the actual handshake to establish a connection to the server.
|
int |
getPhase()
Return the phase value of this object.
|
AsyncListenableTaskExecutor |
getTaskExecutor()
Return the configured
TaskExecutor. |
protected Principal |
getUser() |
boolean |
isAutoStartup()
Return whether this Lifecycle component should be started automatically
by the container when the ApplicationContext is refreshed.
|
boolean |
isRunning()
Check whether this component is currently running.
|
void |
setAutoStartup(boolean autoStartup) |
void |
setPhase(int phase) |
void |
setTaskExecutor(AsyncListenableTaskExecutor taskExecutor)
Set an
AsyncListenableTaskExecutor to use when opening connections. |
void |
start()
Start this component.
|
void |
stop()
Stop this component, typically in a synchronous fashion, such that
the component is fully stopped upon return of this method.
|
void |
stop(Runnable callback)
Indicates that a Lifecycle component must stop if it is currently running.
|
doHandshakepublic JettyWebSocketClient()
WebSocketClient.public JettyWebSocketClient(org.eclipse.jetty.websocket.client.WebSocketClient client)
WebSocketClient instance.public void setTaskExecutor(AsyncListenableTaskExecutor taskExecutor)
AsyncListenableTaskExecutor to use when opening connections.
If this property is not configured, calls to any of the
doHandshake methods will block until the connection is established.
public AsyncListenableTaskExecutor getTaskExecutor()
TaskExecutor.public void setAutoStartup(boolean autoStartup)
public boolean isAutoStartup()
SmartLifecycleisAutoStartup in interface SmartLifecyclepublic void setPhase(int phase)
public int getPhase()
Phasedpublic boolean isRunning()
LifecycleIn the case of a container, this will return true
only if all components that apply are currently running.
public void start()
LifecycleIn the case of a container, this will propagate the start signal to all components that apply.
public void stop()
LifecycleSmartLifecycle and its stop(Runnable)
variant in cases where asynchronous stop behavior is necessary.
Should not throw an exception if the component isn't started yet.
In the case of a container, this will propagate the stop signal to all components that apply.
stop in interface LifecycleSmartLifecycle.stop(Runnable)public void stop(Runnable callback)
SmartLifecycleThe provided callback is used by the LifecycleProcessor to support an
ordered, and potentially concurrent, shutdown of all components having a
common shutdown order value. The callback must be executed after
the SmartLifecycle component does indeed stop.
The LifecycleProcessor will call only this variant of the
stop method; i.e. Lifecycle.stop() will not be called for
SmartLifecycle implementations unless explicitly delegated to within
this method.
stop in interface SmartLifecyclepublic ListenableFuture<WebSocketSession> doHandshake(WebSocketHandler webSocketHandler, String uriTemplate, Object... uriVars)
doHandshake in interface WebSocketClientdoHandshake in class AbstractWebSocketClientpublic ListenableFuture<WebSocketSession> doHandshakeInternal(WebSocketHandler wsHandler, HttpHeaders headers, URI uri, List<String> protocols, List<WebSocketExtension> extensions, Map<String,Object> attributes)
AbstractWebSocketClientdoHandshakeInternal in class AbstractWebSocketClientwsHandler - the client-side handler for WebSocket messagesheaders - HTTP headers to use for the handshake, with unwanted (forbidden)
headers filtered out, never nulluri - the target URI for the handshake, never nullprotocols - requested sub-protocols, or an empty listextensions - requested WebSocket extensions, or an empty listattributes - attributes to associate with the WebSocketSession, i.e. via
WebSocketSession.getAttributes(); currently always an empty map.protected Principal getUser()
WebSocketSession.getPrincipal();
by default this method returns null