类 ConnectionManagerSupport
- java.lang.Object
- org.springframework.web.socket.client.ConnectionManagerSupport
- 所有已实现的接口:
Lifecycle
,Phased
,SmartLifecycle
public abstract class ConnectionManagerSupport extends Object implements SmartLifecycle
A base class for WebSocket connection managers. Provides a declarative style of connecting to a WebSocket server given a URI to connect to. The connection occurs when the Spring ApplicationContext is refreshed, if theautoStartup
property is set totrue
, or if set tofalse
, thestart()
and #stop methods can be invoked manually.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 ConnectionManagerSupport(String uriTemplate, Object... uriVariables)
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 protected abstract void
closeConnection()
int
getPhase()
Return the phase in which this endpoint connection factory will be auto-connected and stopped.protected URI
getUri()
boolean
isAutoStartup()
Return the value for the 'autoStartup' property.protected abstract boolean
isConnected()
boolean
isRunning()
Return whether this ConnectionManager has been started.protected abstract void
openConnection()
void
setAutoStartup(boolean autoStartup)
Set whether to auto-connect to the remote endpoint after this connection manager has been initialized and the Spring context has been refreshed.void
setPhase(int phase)
Specify the phase in which a connection should be established to the remote endpoint and subsequently closed.void
start()
Start the WebSocket connection.protected void
startInternal()
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.protected void
stopInternal()
构造器详细资料
ConnectionManagerSupport
public ConnectionManagerSupport(String uriTemplate, Object... uriVariables)
方法详细资料
setAutoStartup
public void setAutoStartup(boolean autoStartup)
Set whether to auto-connect to the remote endpoint after this connection manager has been initialized and the Spring context has been refreshed.Default is "false".
isAutoStartup
public boolean isAutoStartup()
Return the value for the 'autoStartup' property. If "true", this endpoint connection manager will connect to the remote endpoint upon a ContextRefreshedEvent.
setPhase
public void setPhase(int phase)
Specify the phase in which a connection should be established to the remote endpoint and subsequently closed. The startup order proceeds from lowest to highest, and the shutdown order is the reverse of that. By default this value is Integer.MAX_VALUE meaning that this endpoint connection factory connects as late as possible and is closed as soon as possible.
getPhase
public int getPhase()
Return the phase in which this endpoint connection factory will be auto-connected and stopped.
start
public final void start()
Start the WebSocket connection. If already connected, the method has no impact.- 指定者:
start
在接口中Lifecycle
- 另请参阅:
SmartLifecycle.isAutoStartup()
startInternal
protected void startInternal()
stop
public final void stop()
从接口复制的说明:Lifecycle
Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method. Consider implementingSmartLifecycle
and itsstop(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.
- 指定者:
stop
在接口中Lifecycle
- 另请参阅:
SmartLifecycle.stop(Runnable)
,DisposableBean.destroy()
stop
public final void stop(Runnable callback)
从接口复制的说明:SmartLifecycle
Indicates that a Lifecycle component must stop if it is currently running.The 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 theSmartLifecycle
component does indeed stop.The
LifecycleProcessor
will call only this variant of thestop
method; i.e.Lifecycle.stop()
will not be called forSmartLifecycle
implementations unless explicitly delegated to within the implementation of this method.- 指定者:
stop
在接口中SmartLifecycle
- 另请参阅:
Lifecycle.stop()
,Phased.getPhase()
stopInternal
protected void stopInternal() throws Exception
- 抛出:
Exception
isRunning
public boolean isRunning()
Return whether this ConnectionManager has been started.
openConnection
protected abstract void openConnection()
closeConnection
protected abstract void closeConnection() throws Exception
- 抛出:
Exception
isConnected
protected abstract boolean isConnected()