Top Description Methods
javax.websocket

public Interface WebSocketContainer

Imports
java.io.*, java.net.URI, java.util.Set

A WebSocketContainer is an implementation provided object that provides applications a view on the container running it. The WebSocketContainer container various configuration parameters that control default session and buffer properties of the endpoints it contains. It also allows the developer to deploy websocket client endpoints by initiating a web socket handshake from the provided endpoint to a supplied URI where the peer endpoint is presumed to reside.

A WebSocketContainer may be accessed by concurrent threads, so implementations must ensure the integrity of its mutable attributes in such circumstances.

Author
dannycoward

Method Summary

Modifier and TypeMethod and Description
public Session

Returns:

the Session created if the connection is successful.
connectToServer
(Object
the annotated websocket client endpoint instance.
annotatedEndpointInstance
,
URI
the complete path to the server endpoint.
path
)

Connect the supplied annotated endpoint instance to its server.

public Session

Returns:

the Session created if the connection is successful.
connectToServer
(Class<?>
the annotated websocket client endpoint.
annotatedEndpointClass
,
URI
the complete path to the server endpoint.
path
)

Connect the supplied annotated endpoint to its server.

public Session

Returns:

the Session created if the connection is successful.
connectToServer
(Endpoint
the programmatic client endpoint instance Endpoint.
endpointInstance
,
ClientEndpointConfig
the configuration used to configure the programmatic endpoint.
cec
,
URI
the complete path to the server endpoint.
path
)

Connect the supplied programmatic client endpoint instance to its server with the given configuration.

public Session

Returns:

the Session created if the connection is successful.
connectToServer
(Class<? extends Endpoint>
the programmatic client endpoint class Endpoint.
endpointClass
,
ClientEndpointConfig
the configuration used to configure the programmatic endpoint.
cec
,
URI
the complete path to the server endpoint.
path
)

Connect the supplied programmatic endpoint to its server with the given configuration.

public long

Returns:

the timeout time in millsenconds.
getDefaultAsyncSendTimeout
()

Return the number of milliseconds the implementation will timeout attempting to send a websocket message for all RemoteEndpoints associated with this container.

public int

Returns:

the maximum size of incoming binary message in number of bytes.
getDefaultMaxBinaryMessageBufferSize
()

Returns the default maximum size of incoming binary message that this container will buffer.

public long

Returns:

the default number of milliseconds after which an idle session in this container will be closed
getDefaultMaxSessionIdleTimeout
()

Return the default time in milliseconds after which any web socket sessions in this container will be closed if it has been inactive.

public int

Returns:

the maximum size of incoming text message in number of bytes.
getDefaultMaxTextMessageBufferSize
()

Returns the default maximum size of incoming text message that this container will buffer.

public Set<Extension>

Returns:

the set of extensions.
getInstalledExtensions
()

Return the set of Extensions installed in the container.

public void
setAsyncSendTimeout(long timeoutmillis)

Sets the number of milliseconds the implementation will timeout attempting to send a websocket message for all RemoteEndpoints associated with this container.

public void
setDefaultMaxBinaryMessageBufferSize(int
the maximum size of binary message in number of bytes.
max
)

Sets the default maximum size of incoming binary message that this container will buffer.

public void
setDefaultMaxSessionIdleTimeout(long
the maximum time in milliseconds.
timeout
)

Sets the default time in milliseconds after which any web socket sessions in this container will be closed if it has been inactive.

public void
setDefaultMaxTextMessageBufferSize(int
the maximum size of text message in number of bytes.
max
)

Sets the maximum size of incoming text message that this container will buffer.

Method Detail

connectToServerback to summary
public Session connectToServer(Object annotatedEndpointInstance, URI path) throws DeploymentException, IOException

Connect the supplied annotated endpoint instance to its server. The supplied object must be a class decorated with the class level javax.websocket.server.ServerEndpoint annotation. This method blocks until the connection is established, or throws an error if either the connection could not be made or there was a problem with the supplied endpoint class. If the developer uses this method to deploy the client endpoint, services like dependency injection that are supported, for example, when the implementation is part of the Java EE platform may not be available. If the client endpoint uses dependency injection, use WebSocketContainer#connectToServer(java.lang.Class, java.net.URI) instead.

Parameters
annotatedEndpointInstance:Object

the annotated websocket client endpoint instance.

path:URI

the complete path to the server endpoint.

Returns:Session

the Session created if the connection is successful.

Exceptions
DeploymentException:
if the annotated endpoint instance is not valid.
IOException:
if there was a network or protocol problem that prevented the client endpoint being connected to its server.
IllegalStateException:
if called during the deployment phase of the containing application.
connectToServerback to summary
public Session connectToServer(Class<?> annotatedEndpointClass, URI path) throws DeploymentException, IOException

Connect the supplied annotated endpoint to its server. The supplied object must be a class decorated with the class level javax.websocket.server.ServerEndpoint annotation. This method blocks until the connection is established, or throws an error if either the connection could not be made or there was a problem with the supplied endpoint class.

Parameters
annotatedEndpointClass:Class<?>

the annotated websocket client endpoint.

path:URI

the complete path to the server endpoint.

Returns:Session

the Session created if the connection is successful.

Exceptions
DeploymentException:
if the class is not a valid annotated endpoint class.
IOException:
if there was a network or protocol problem that prevented the client endpoint being connected to its server.
IllegalStateException:
if called during the deployment phase of the containing application.
connectToServerback to summary
public Session connectToServer(Endpoint endpointInstance, ClientEndpointConfig cec, URI path) throws DeploymentException, IOException

Connect the supplied programmatic client endpoint instance to its server with the given configuration. This method blocks until the connection is established, or throws an error if the connection could not be made. If the developer uses this method to deploy the client endpoint, services like dependency injection that are supported, for example, when the implementation is part of the Java EE platform may not be available. If the client endpoint uses dependency injection, use WebSocketContainer#connectToServer(java.lang.Class, javax.websocket.ClientEndpointConfig, java.net.URI) instead.

Parameters
endpointInstance:Endpoint

the programmatic client endpoint instance Endpoint.

cec:ClientEndpointConfig

the configuration used to configure the programmatic endpoint.

path:URI

the complete path to the server endpoint.

Returns:Session

the Session created if the connection is successful.

Exceptions
DeploymentException:
if the configuration is not valid
IOException:
if there was a network or protocol problem that prevented the client endpoint being connected to its server
IllegalStateException:
if called during the deployment phase of the containing application.
connectToServerback to summary
public Session connectToServer(Class<? extends Endpoint> endpointClass, ClientEndpointConfig cec, URI path) throws DeploymentException, IOException

Connect the supplied programmatic endpoint to its server with the given configuration. This method blocks until the connection is established, or throws an error if the connection could not be made.

Parameters
endpointClass:Class<? extends Endpoint>

the programmatic client endpoint class Endpoint.

cec:ClientEndpointConfig

the configuration used to configure the programmatic endpoint.

path:URI

the complete path to the server endpoint.

Returns:Session

the Session created if the connection is successful.

Exceptions
DeploymentException:
if the configuration is not valid
IOException:
if there was a network or protocol problem that prevented the client endpoint being connected to its server
IllegalStateException:
if called during the deployment phase of the containing application.
getDefaultAsyncSendTimeoutback to summary
public long getDefaultAsyncSendTimeout()

Return the number of milliseconds the implementation will timeout attempting to send a websocket message for all RemoteEndpoints associated with this container. A non-positive number indicates the implementation will not timeout attempting to send a websocket message asynchronously. Note this default may be overridden in each RemoteEndpoint.

Returns:long

the timeout time in millsenconds.

getDefaultMaxBinaryMessageBufferSizeback to summary
public int getDefaultMaxBinaryMessageBufferSize()

Returns the default maximum size of incoming binary message that this container will buffer. This default may be overridden on a per session basis using Session#setMaxBinaryMessageBufferSize(int)

Returns:int

the maximum size of incoming binary message in number of bytes.

getDefaultMaxSessionIdleTimeoutback to summary
public long getDefaultMaxSessionIdleTimeout()

Return the default time in milliseconds after which any web socket sessions in this container will be closed if it has been inactive. A value that is 0 or negative indicates the sessions will never timeout due to inactivity. The value may be overridden on a per session basis using Session#setMaxIdleTimeout(long)

Returns:long

the default number of milliseconds after which an idle session in this container will be closed

getDefaultMaxTextMessageBufferSizeback to summary
public int getDefaultMaxTextMessageBufferSize()

Returns the default maximum size of incoming text message that this container will buffer. This default may be overridden on a per session basis using Session#setMaxTextMessageBufferSize(int)

Returns:int

the maximum size of incoming text message in number of bytes.

getInstalledExtensionsback to summary
public Set<Extension> getInstalledExtensions()

Return the set of Extensions installed in the container.

Returns:Set<Extension>

the set of extensions.

setAsyncSendTimeoutback to summary
public void setAsyncSendTimeout(long timeoutmillis)

Sets the number of milliseconds the implementation will timeout attempting to send a websocket message for all RemoteEndpoints associated with this container. A non-positive number indicates the implementation will not timeout attempting to send a websocket message asynchronously. Note this default may be overridden in each RemoteEndpoint.

setDefaultMaxBinaryMessageBufferSizeback to summary
public void setDefaultMaxBinaryMessageBufferSize(int max)

Sets the default maximum size of incoming binary message that this container will buffer.

Parameters
max:int

the maximum size of binary message in number of bytes.

setDefaultMaxSessionIdleTimeoutback to summary
public void setDefaultMaxSessionIdleTimeout(long timeout)

Sets the default time in milliseconds after which any web socket sessions in this container will be closed if it has been inactive. A value that is 0 or negative indicates the sessions will never timeout due to inactivity. The value may be overridden on a per session basis using Session#setMaxIdleTimeout(long)

Parameters
timeout:long

the maximum time in milliseconds.

setDefaultMaxTextMessageBufferSizeback to summary
public void setDefaultMaxTextMessageBufferSize(int max)

Sets the maximum size of incoming text message that this container will buffer.

Parameters
max:int

the maximum size of text message in number of bytes.