org.springframework.web.socket.client

## Class ConnectionManagerSupport

- java.lang.Object
- - org.springframework.web.socket.client.ConnectionManagerSupport

All Implemented Interfaces:
  org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle

Direct Known Subclasses:
  AnnotatedEndpointConnectionManager, EndpointConnectionManager, WebSocketConnectionManager

    public abstract class ConnectionManagerSupport
    extends Object
    implements org.springframework.context.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 the `autoStartup` property is set to `true`, or if set to `false`, the `start()` and #stop methods can be invoked manually.

Since:
  4.0
Author:
  Rossen Stoyanchev

### Field Summary

Fields
`protected Log` `logger`

### Fields inherited from interface org.springframework.context.SmartLifecycle

`DEFAULT_PHASE`

### Constructor Summary

Constructors
Constructor and Description
`ConnectionManagerSupport(String uriTemplate, Object... uriVariables)`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`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()`
`void` `stop(Runnable callback)`
`protected void` `stopInternal()`

### Methods inherited from class java.lang.Object

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

### Field Detail

#### logger

    protected final Log logger

### Constructor Detail

#### ConnectionManagerSupport

    public ConnectionManagerSupport(String uriTemplate,
                                    Object... uriVariables)

### Method Detail

#### getUri

    protected URI getUri()

#### 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.

Specified by:
  `isAutoStartup` in interface `org.springframework.context.SmartLifecycle`

#### 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.

Specified by:
  `getPhase` in interface `org.springframework.context.Phased`
Specified by:
  `getPhase` in interface `org.springframework.context.SmartLifecycle`

#### start

    public final void start()

Start the WebSocket connection. If already connected, the method has no impact.

Specified by:
  `start` in interface `org.springframework.context.Lifecycle`

#### startInternal

    protected void startInternal()

#### stop

    public final void stop()

Specified by:
  `stop` in interface `org.springframework.context.Lifecycle`

#### stop

    public final void stop(Runnable callback)

Specified by:
  `stop` in interface `org.springframework.context.SmartLifecycle`

#### stopInternal

    protected void stopInternal()
                         throws Exception

Throws:
  `Exception`

#### isRunning

    public boolean isRunning()

Return whether this ConnectionManager has been started.

Specified by:
  `isRunning` in interface `org.springframework.context.Lifecycle`

#### openConnection

    protected abstract void openConnection()

#### closeConnection

    protected abstract void closeConnection()
                                     throws Exception

Throws:
  `Exception`

#### isConnected

    protected abstract boolean isConnected()