public abstract class TyrusServerContainer extends BaseContainer implements ServerContainer
BaseContainer.ShutDownCondition
Constructor and Description |
---|
TyrusServerContainer(ServerApplicationConfig serverApplicationConfig)
Create new
TyrusServerContainer using already created ServerApplicationConfig instance. |
TyrusServerContainer(Set<Class<?>> classes)
Create new
TyrusServerContainer . |
Modifier and Type | Method and Description |
---|---|
void |
addEndpoint(Class<?> endpointClass)
Deploys the given annotated endpoint into this ServerContainer during the initialization phase of deploying the
application.
|
void |
addEndpoint(ServerEndpointConfig serverEndpointConfig) |
Future<Session> |
asyncConnectToServer(Class<?> annotatedEndpointClass,
URI path)
Non-blocking version of
WebSocketContainer.connectToServer(Class, java.net.URI) . |
Future<Session> |
asyncConnectToServer(Class<? extends Endpoint> endpointClass,
ClientEndpointConfig cec,
URI path)
Non-blocking version of
WebSocketContainer.connectToServer(Class,
javax.websocket.ClientEndpointConfig, java.net.URI) . |
Future<Session> |
asyncConnectToServer(Endpoint endpointInstance,
ClientEndpointConfig cec,
URI path)
|
Future<Session> |
asyncConnectToServer(Object obj,
URI path)
Non-blocking version of
WebSocketContainer.connectToServer(Object, java.net.URI) . |
Session |
connectToServer(Class<? extends Endpoint> endpointClass,
ClientEndpointConfig cec,
URI path)
Connect the supplied programmatic endpoint to its server with the given configuration.
|
Session |
connectToServer(Class annotatedEndpointClass,
URI path)
Connect the supplied annotated endpoint to its server.
|
Session |
connectToServer(Endpoint endpointInstance,
ClientEndpointConfig cec,
URI path)
Connect the supplied programmatic client endpoint instance to its server with the given configuration.
|
Session |
connectToServer(Object annotatedEndpointInstance,
URI path)
Connect the supplied annotated endpoint instance to its server.
|
void |
doneDeployment()
Container is no longer required to accept
addEndpoint(javax.websocket.server.ServerEndpointConfig) and
addEndpoint(Class) calls. |
protected ClientManager |
getClientManager()
Can be overridden to provide own
ClientManager implementation or instance. |
long |
getDefaultAsyncSendTimeout()
Return the number of milliseconds the implementation will timeout attempting to send a websocket message for all
RemoteEndpoints associated with this container.
|
int |
getDefaultMaxBinaryMessageBufferSize()
Returns the default maximum size of incoming binary message that this container will buffer.
|
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.
|
int |
getDefaultMaxTextMessageBufferSize()
Returns the default maximum size of incoming text message that this container will buffer.
|
Set<Extension> |
getInstalledExtensions()
Return the set of Extensions installed in the container.
|
int |
getPort()
Get port of the started container.
|
abstract void |
register(Class<?> endpointClass) |
abstract void |
register(ServerEndpointConfig serverEndpointConfig) |
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.
|
void |
setDefaultMaxBinaryMessageBufferSize(int max)
Sets the default maximum size of incoming binary message that this container will buffer.
|
void |
setDefaultMaxSessionIdleTimeout(long defaultMaxSessionIdleTimeout)
Sets the default time in milliseconds after which any web socket sessions in this container will be closed if it
has been inactive.
|
void |
setDefaultMaxTextMessageBufferSize(int max)
Sets the maximum size of incoming text message that this container will buffer.
|
void |
start(String rootPath,
int port)
Start the container.
|
void |
stop()
Undeploy all endpoints and stop underlying
ServerContainer . |
getExecutorService, getScheduledExecutorService, shutdown, shutdown
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getWebSocketEngine
public TyrusServerContainer(Set<Class<?>> classes)
TyrusServerContainer
.classes
- classes to be included in this application instance. Can contain any combination of annotated
endpoints (see ServerEndpoint
) or Endpoint
descendants.public TyrusServerContainer(ServerApplicationConfig serverApplicationConfig)
TyrusServerContainer
using already created ServerApplicationConfig
instance.serverApplicationConfig
- provided application config.public void start(String rootPath, int port) throws IOException, DeploymentException
rootPath
- context path of the deployed websocket application.port
- TCP portIOException
- when any IO related issues emerge during ServerContainer.start(String, int)
.DeploymentException
- when any deployment related error is found; should contain list of all found issues.public void stop()
ServerContainer
.
Release all created threadpools / executor services.
public abstract void register(Class<?> endpointClass) throws DeploymentException
DeploymentException
public abstract void register(ServerEndpointConfig serverEndpointConfig) throws DeploymentException
DeploymentException
public void addEndpoint(Class<?> endpointClass) throws DeploymentException
ServerContainer
addEndpoint
in interface ServerContainer
endpointClass
- the class of the annotated endpointDeploymentException
- if the annotated endpoint was badly formed.public void addEndpoint(ServerEndpointConfig serverEndpointConfig) throws DeploymentException
addEndpoint
in interface ServerContainer
serverEndpointConfig
- the configuration instance representing the logical endpoint that will be registered.DeploymentException
- if the endpoint was badly formed.public int getPort()
-1
, when the container is not started or the container does
not provide the port.protected ClientManager getClientManager()
ClientManager
implementation or instance.ClientManager
associated with this server container.public Session connectToServer(Class annotatedEndpointClass, URI path) throws DeploymentException, IOException
WebSocketContainer
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.connectToServer
in interface WebSocketContainer
annotatedEndpointClass
- the annotated websocket client endpoint.path
- the complete path to the server endpoint.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.public Session connectToServer(Class<? extends Endpoint> endpointClass, ClientEndpointConfig cec, URI path) throws DeploymentException, IOException
WebSocketContainer
connectToServer
in interface WebSocketContainer
endpointClass
- the programmatic client endpoint class Endpoint
.cec
- the configuration used to configure the programmatic endpoint.path
- the complete path to the server endpoint.DeploymentException
- if the configuration is not validIOException
- if there was a network or protocol problem that prevented the client endpoint being
connected to its serverpublic Session connectToServer(Object annotatedEndpointInstance, URI path) throws DeploymentException, IOException
WebSocketContainer
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.connectToServer
in interface WebSocketContainer
annotatedEndpointInstance
- the annotated websocket client endpoint instance.path
- the complete path to the server endpoint.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.public Session connectToServer(Endpoint endpointInstance, ClientEndpointConfig cec, URI path) throws DeploymentException, IOException
WebSocketContainer
WebSocketContainer.connectToServer(java.lang.Class, javax.websocket.ClientEndpointConfig, java.net.URI)
instead.connectToServer
in interface WebSocketContainer
endpointInstance
- the programmatic client endpoint instance Endpoint
.cec
- the configuration used to configure the programmatic endpoint.path
- the complete path to the server endpoint.DeploymentException
- if the configuration is not validIOException
- if there was a network or protocol problem that prevented the client endpoint being
connected to its serverpublic Future<Session> asyncConnectToServer(Class<?> annotatedEndpointClass, URI path) throws DeploymentException
WebSocketContainer.connectToServer(Class, java.net.URI)
.
Only simple checks are performed in the main thread; client container is created in different thread, same applies to connecting etc.
annotatedEndpointClass
- the annotated websocket client endpoint.path
- the complete path to the server endpoint.DeploymentException
- if the class is not a valid annotated endpoint class.public Future<Session> asyncConnectToServer(Class<? extends Endpoint> endpointClass, ClientEndpointConfig cec, URI path) throws DeploymentException
WebSocketContainer.connectToServer(Class,
javax.websocket.ClientEndpointConfig, java.net.URI)
.
Only simple checks are performed in the main thread; client container is created in different thread, same applies to connecting etc.
endpointClass
- the programmatic client endpoint class Endpoint
.path
- the complete path to the server endpoint.cec
- the configuration used to configure the programmatic endpoint.DeploymentException
- if the configuration is not validWebSocketContainer.connectToServer(Class, javax.websocket.ClientEndpointConfig,
java.net.URI)
public Future<Session> asyncConnectToServer(Endpoint endpointInstance, ClientEndpointConfig cec, URI path) throws DeploymentException
WebSocketContainer.connectToServer(javax.websocket.Endpoint,
javax.websocket.ClientEndpointConfig, java.net.URI)
.
Only simple checks are performed in the main thread; client container is created in different thread, same applies to connecting etc.
endpointInstance
- the programmatic client endpoint instance Endpoint
.path
- the complete path to the server endpoint.cec
- the configuration used to configure the programmatic endpoint.DeploymentException
- if the configuration is not validWebSocketContainer.connectToServer(javax.websocket.Endpoint,
javax.websocket.ClientEndpointConfig, java.net.URI)
public Future<Session> asyncConnectToServer(Object obj, URI path) throws DeploymentException
WebSocketContainer.connectToServer(Object, java.net.URI)
.
Only simple checks are performed in the main thread; client container is created in different thread, same applies to connecting etc.
obj
- the annotated websocket client endpoint instance.path
- the complete path to the server endpoint.DeploymentException
- if the annotated endpoint instance is not valid.WebSocketContainer.connectToServer(Object, java.net.URI)
public int getDefaultMaxBinaryMessageBufferSize()
WebSocketContainer
Session.setMaxBinaryMessageBufferSize(int)
getDefaultMaxBinaryMessageBufferSize
in interface WebSocketContainer
public void setDefaultMaxBinaryMessageBufferSize(int max)
WebSocketContainer
setDefaultMaxBinaryMessageBufferSize
in interface WebSocketContainer
max
- the maximum size of binary message in number of bytes.public int getDefaultMaxTextMessageBufferSize()
WebSocketContainer
Session.setMaxTextMessageBufferSize(int)
getDefaultMaxTextMessageBufferSize
in interface WebSocketContainer
public void setDefaultMaxTextMessageBufferSize(int max)
WebSocketContainer
setDefaultMaxTextMessageBufferSize
in interface WebSocketContainer
max
- the maximum size of text message in number of bytes.public Set<Extension> getInstalledExtensions()
WebSocketContainer
getInstalledExtensions
in interface WebSocketContainer
public long getDefaultAsyncSendTimeout()
WebSocketContainer
getDefaultAsyncSendTimeout
in interface WebSocketContainer
public void setAsyncSendTimeout(long timeoutmillis)
WebSocketContainer
setAsyncSendTimeout
in interface WebSocketContainer
timeoutmillis
- the timeout in milliseconds or a non-positive number for no timeoutpublic long getDefaultMaxSessionIdleTimeout()
WebSocketContainer
Session.setMaxIdleTimeout(long)
getDefaultMaxSessionIdleTimeout
in interface WebSocketContainer
public void setDefaultMaxSessionIdleTimeout(long defaultMaxSessionIdleTimeout)
WebSocketContainer
Session.setMaxIdleTimeout(long)
setDefaultMaxSessionIdleTimeout
in interface WebSocketContainer
defaultMaxSessionIdleTimeout
- the maximum time in milliseconds.public void doneDeployment()
addEndpoint(javax.websocket.server.ServerEndpointConfig)
and
addEndpoint(Class)
calls.Copyright © 2012–2019 Oracle Corporation. All rights reserved.