org.apache.tomcat.websocket

## Class WsWebSocketContainer

- java.lang.Object
- - org.apache.tomcat.websocket.WsWebSocketContainer

All Implemented Interfaces:
  WebSocketContainer, BackgroundProcess

Direct Known Subclasses:
  WsServerContainer

    public class WsWebSocketContainer
    extends Object
    implements WebSocketContainer, BackgroundProcess

### Field Summary

Fields
`static long` `IO_TIMEOUT_MS_DEFAULT`
`static String` `IO_TIMEOUT_MS_PROPERTY` Property name to set to configure the timeout (in milliseconds) when establishing a WebSocket connection to server.
`static String` `SSL_CONTEXT_PROPERTY` Property name to set to configure used SSLContext.
`static String` `SSL_PROTOCOLS_PROPERTY` Property name to set to configure the value that is passed to `SSLEngine.setEnabledProtocols(String[])`.
`static String` `SSL_TRUSTSTORE_PROPERTY`
`static String` `SSL_TRUSTSTORE_PWD_DEFAULT`
`static String` `SSL_TRUSTSTORE_PWD_PROPERTY`

### Constructor Summary

Constructors
Constructor and Description
`WsWebSocketContainer()`

### Method Summary

Methods
`void` `backgroundProcess()`
`Session` `connectToServer(Class<?> annotatedEndpointClass, URI path)`
`Session` `connectToServer(Class<? extends Endpoint> clazz, ClientEndpointConfig clientEndpointConfiguration, URI path)` Creates a new connection to the WebSocket.
`Session` `connectToServer(Endpoint endpoint, ClientEndpointConfig clientEndpointConfiguration, URI path)` Creates a new connection to the WebSocket.
`Session` `connectToServer(Object pojo, URI path)`
`void` `destroy()` Cleans up the resources still in use by WebSocket sessions created from this container.
`long` `getDefaultAsyncSendTimeout()` Obtain the default timeout (in milliseconds) for sending a message asynchronously.
`int` `getDefaultMaxBinaryMessageBufferSize()` Get the default maximum buffer size (in bytes) for binary messages.
`long` `getDefaultMaxSessionIdleTimeout()` Get the current default session idle timeout in milliseconds.
`int` `getDefaultMaxTextMessageBufferSize()` Get the default maximum buffer size (in characters) for text messages.
`Set<Extension>` `getInstalledExtensions()` Get the set of extensions that are supported by this WebSocket implementation.
`int` `getProcessPeriod()` The default value is 10 which means session expirations are processed every 10 seconds.
`protected void` `registerSession(Endpoint endpoint, WsSession wsSession)`
`void` `setAsyncSendTimeout(long timeout)` Set the default timeout (in milliseconds) for sending a message asynchronously.
`void` `setDefaultMaxBinaryMessageBufferSize(int max)` Set the default maximum buffer size (in bytes) for binary messages.
`void` `setDefaultMaxSessionIdleTimeout(long timeout)` Set the current default session idle timeout in milliseconds.
`void` `setDefaultMaxTextMessageBufferSize(int max)` Set the default maximum buffer size (in characters) for text messages.
`void` `setProcessPeriod(int period)`
`protected void` `unregisterSession(Endpoint endpoint, WsSession wsSession)`

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

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

### Field Detail

#### SSL_PROTOCOLS_PROPERTY

    public static final String SSL_PROTOCOLS_PROPERTY

Property name to set to configure the value that is passed to `SSLEngine.setEnabledProtocols(String[])`. The value should be a comma separated string.

See Also:
  Constant Field Values

#### SSL_TRUSTSTORE_PROPERTY

    public static final String SSL_TRUSTSTORE_PROPERTY

See Also:
  Constant Field Values

#### SSL_TRUSTSTORE_PWD_PROPERTY

    public static final String SSL_TRUSTSTORE_PWD_PROPERTY

See Also:
  Constant Field Values

#### SSL_TRUSTSTORE_PWD_DEFAULT

    public static final String SSL_TRUSTSTORE_PWD_DEFAULT

See Also:
  Constant Field Values

#### SSL_CONTEXT_PROPERTY

    public static final String SSL_CONTEXT_PROPERTY

Property name to set to configure used SSLContext. The value should be an instance of SSLContext. If this property is present, the SSL_TRUSTSTORE* properties are ignored.

See Also:
  Constant Field Values

#### IO_TIMEOUT_MS_PROPERTY

    public static final String IO_TIMEOUT_MS_PROPERTY

Property name to set to configure the timeout (in milliseconds) when establishing a WebSocket connection to server. The default is `IO_TIMEOUT_MS_DEFAULT`.

See Also:
  Constant Field Values

#### IO_TIMEOUT_MS_DEFAULT

    public static final long IO_TIMEOUT_MS_DEFAULT

See Also:
  Constant Field Values

### Constructor Detail

#### WsWebSocketContainer

    public WsWebSocketContainer()

### Method Detail

#### connectToServer

    public Session connectToServer(Object pojo,
                          URI path)
                            throws DeploymentException

Specified by:
  `connectToServer` in interface `WebSocketContainer`
Throws:
  `DeploymentException`

#### connectToServer

    public Session connectToServer(Class<?> annotatedEndpointClass,
                          URI path)
                            throws DeploymentException

Specified by:
  `connectToServer` in interface `WebSocketContainer`
Throws:
  `DeploymentException`

#### connectToServer

    public Session connectToServer(Class<? extends Endpoint> clazz,
                          ClientEndpointConfig clientEndpointConfiguration,
                          URI path)
                            throws DeploymentException

Description copied from interface: `javax.websocket.WebSocketContainer`
Creates a new connection to the WebSocket.

Specified by:
  `connectToServer` in interface `WebSocketContainer`
Parameters:
  `clazz` - An instance of this class will be created to handle responses from the server
  `clientEndpointConfiguration` - Used to configure the new connection
  `path` - The full URL of the WebSocket endpoint to connect to
Returns:
  The WebSocket session for the connection
Throws:
  `DeploymentException` - If the connection can not be established

#### connectToServer

    public Session connectToServer(Endpoint endpoint,
                          ClientEndpointConfig clientEndpointConfiguration,
                          URI path)
                            throws DeploymentException

Description copied from interface: `javax.websocket.WebSocketContainer`
Creates a new connection to the WebSocket.

Specified by:
  `connectToServer` in interface `WebSocketContainer`
Parameters:
  `endpoint` - The endpoint instance that will handle responses from the server
  `clientEndpointConfiguration` - Used to configure the new connection
  `path` - The full URL of the WebSocket endpoint to connect to
Returns:
  The WebSocket session for the connection
Throws:
  `DeploymentException` - If the connection can not be established

#### registerSession

    protected void registerSession(Endpoint endpoint,
                       WsSession wsSession)

#### unregisterSession

    protected void unregisterSession(Endpoint endpoint,
                         WsSession wsSession)

#### getDefaultMaxSessionIdleTimeout

    public long getDefaultMaxSessionIdleTimeout()

Description copied from interface: `javax.websocket.WebSocketContainer`
Get the current default session idle timeout in milliseconds. Zero or negative values indicate an infinite timeout.

Specified by:
  `getDefaultMaxSessionIdleTimeout` in interface `WebSocketContainer`

#### setDefaultMaxSessionIdleTimeout

    public void setDefaultMaxSessionIdleTimeout(long timeout)

Description copied from interface: `javax.websocket.WebSocketContainer`
Set the current default session idle timeout in milliseconds. Zero or negative values indicate an infinite timeout.

Specified by:
  `setDefaultMaxSessionIdleTimeout` in interface `WebSocketContainer`

#### getDefaultMaxBinaryMessageBufferSize

    public int getDefaultMaxBinaryMessageBufferSize()

Description copied from interface: `javax.websocket.WebSocketContainer`
Get the default maximum buffer size (in bytes) for binary messages.

Specified by:
  `getDefaultMaxBinaryMessageBufferSize` in interface `WebSocketContainer`

#### setDefaultMaxBinaryMessageBufferSize

    public void setDefaultMaxBinaryMessageBufferSize(int max)

Description copied from interface: `javax.websocket.WebSocketContainer`
Set the default maximum buffer size (in bytes) for binary messages.

Specified by:
  `setDefaultMaxBinaryMessageBufferSize` in interface `WebSocketContainer`

#### getDefaultMaxTextMessageBufferSize

    public int getDefaultMaxTextMessageBufferSize()

Description copied from interface: `javax.websocket.WebSocketContainer`
Get the default maximum buffer size (in characters) for text messages.

Specified by:
  `getDefaultMaxTextMessageBufferSize` in interface `WebSocketContainer`

#### setDefaultMaxTextMessageBufferSize

    public void setDefaultMaxTextMessageBufferSize(int max)

Description copied from interface: `javax.websocket.WebSocketContainer`
Set the default maximum buffer size (in characters) for text messages.

Specified by:
  `setDefaultMaxTextMessageBufferSize` in interface `WebSocketContainer`

#### getInstalledExtensions

    public Set<Extension> getInstalledExtensions()

Get the set of extensions that are supported by this WebSocket implementation. Currently, this implementation does not support any extensions.

Specified by:
  `getInstalledExtensions` in interface `WebSocketContainer`

#### getDefaultAsyncSendTimeout

    public long getDefaultAsyncSendTimeout()

Obtain the default timeout (in milliseconds) for sending a message asynchronously. A non-positive value means an infinite timeout. The default value for this implementation is -1.

Specified by:
  `getDefaultAsyncSendTimeout` in interface `WebSocketContainer`

#### setAsyncSendTimeout

    public void setAsyncSendTimeout(long timeout)

Set the default timeout (in milliseconds) for sending a message asynchronously. A non-positive value means an infinite timeout. The default value for this implementation is -1.

Specified by:
  `setAsyncSendTimeout` in interface `WebSocketContainer`

#### destroy

    public void destroy()

Cleans up the resources still in use by WebSocket sessions created from this container. This includes closing sessions and cancelling `Future`s associated with blocking read/writes.

#### backgroundProcess

    public void backgroundProcess()

Specified by:
  `backgroundProcess` in interface `BackgroundProcess`

#### setProcessPeriod

    public void setProcessPeriod(int period)

Specified by:
  `setProcessPeriod` in interface `BackgroundProcess`

#### getProcessPeriod

    public int getProcessPeriod()

The default value is 10 which means session expirations are processed every 10 seconds.

Specified by:
  `getProcessPeriod` in interface `BackgroundProcess`