Class ClientManager
- All Implemented Interfaces:
- WebSocketContainer
- Author:
- Stepan Kopriva, Pavel Bucek
- 
Nested Class SummaryNested ClassesNested classes/interfaces inherited from class org.glassfish.tyrus.core.BaseContainerBaseContainer.ShutDownCondition
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringDeprecated.static final StringDeprecated.please useClientProperties.PROXY_HEADERS.static final StringDeprecated.please useClientProperties.PROXY_URI.static final StringDeprecated.please useClientProperties.RECONNECT_HANDLER.static final StringDeprecated.please useClientProperties.SSL_ENGINE_CONFIGURATOR.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionasyncConnectToServer(Endpoint endpointInstance, ClientEndpointConfig cec, URI path) asyncConnectToServer(Class<?> annotatedEndpointClass, URI path) Non-blocking version ofWebSocketContainer.connectToServer(Class, java.net.URI).asyncConnectToServer(Class<? extends Endpoint> endpointClass, ClientEndpointConfig cec, URI path) Non-blocking version ofWebSocketContainer.connectToServer(Class, jakarta.websocket.ClientEndpointConfig, java.net.URI).asyncConnectToServer(Object obj, URI path) Non-blocking version ofWebSocketContainer.connectToServer(Object, java.net.URI).connectToServer(Endpoint endpointInstance, ClientEndpointConfig cec, URI path) Connect the supplied programmatic client endpoint instance to its server with the given configuration.connectToServer(Class<? extends Endpoint> endpointClass, ClientEndpointConfig cec, URI path) Connect the supplied programmatic endpoint to its server with the given configuration.connectToServer(Class annotatedEndpointClass, URI path) Connect the supplied annotated endpoint to its server.connectToServer(Object obj, URI path) Connect the supplied annotated endpoint instance to its server.static ClientManagerCreate newClientManagerinstance.static ClientManagercreateClient(WebSocketContainer webSocketContainer) Create new ClientManager instance on top of providedWebSocketContainerinstance.static ClientManagercreateClient(String containerProviderClassName) Create new ClientManager instance.static ClientManagercreateClient(String containerProviderClassName, WebSocketContainer webSocketContainer) Create new ClientManager instance on top of providedWebSocketContainerinstance.longReturn the number of milliseconds the implementation will timeout attempting to send a websocket message for all RemoteEndpoints associated with this container.intReturns the default maximum size of incoming binary message that this container will buffer.longReturn the default time in milliseconds after which any web socket sessions in this container will be closed if it has been inactive.intReturns the default maximum size of incoming text message that this container will buffer.Return the set of Extensions installed in the container.Container properties.voidsetAsyncSendTimeout(long timeoutmillis) Sets the number of milliseconds the implementation will timeout attempting to send a websocket message for all RemoteEndpoints associated with this container.voidSets the default maximum size of incoming binary message that this container will buffer.voidsetDefaultMaxSessionIdleTimeout(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.voidSets the maximum size of incoming text message that this container will buffer.Methods inherited from class org.glassfish.tyrus.core.BaseContainergetExecutorService, getScheduledExecutorService, shutdown, shutdown
- 
Field Details- 
HANDSHAKE_TIMEOUTDeprecated.please useClientProperties.HANDSHAKE_TIMEOUT.Property usable ingetProperties().Value must be intand represents handshake timeout in milliseconds. Default value is 30000 (30 seconds).- See Also:
 
- 
RECONNECT_HANDLERDeprecated.please useClientProperties.RECONNECT_HANDLER.Property usable ingetProperties().Value must be ClientManager.ReconnectHandlerinstance.- See Also:
 
- 
PROXY_URIDeprecated.please useClientProperties.PROXY_URI.Client-side user property to set proxy URI.Value is expected to be Stringand represent proxy URI. Protocol part is currently ignored but must be present (URI(String)is used for parsing).client.getProperties().put(ClientManager.PROXY_URI, "http://my.proxy.com:80"); client.connectToServer(...);- See Also:
 
- 
PROXY_HEADERSDeprecated.please useClientProperties.PROXY_HEADERS.Client-side user property to set additional proxy headers.Value is expected to be Map<String,String> and represent raw http headers to be added to initial request which is sent to proxy. Key corresponds to header name, value is header value.Sample below demonstrates use of this feature to set preemptive basic proxy authentication: final HashMap<String, String> proxyHeaders = new HashMap<String, String>(); proxyHeaders.put("Proxy-Authorization", "Basic " + Base64.getEncoder().encodeToString("username:password".getBytes(Charset.forName("UTF-8")))); client.getProperties().put(GrizzlyClientSocket.PROXY_HEADERS, proxyHeaders); client.connectToServer(...);Please note that these headers will be used only when establishing proxy connection, for modifying WebSocket handshake headers, seeClientEndpointConfig.Configurator.beforeRequest(java.util.Map).- See Also:
 
- 
SSL_ENGINE_CONFIGURATORDeprecated.please useClientProperties.SSL_ENGINE_CONFIGURATOR.Property usable ingetProperties()as a key for SSL configuration.Value is expected to be either org.glassfish.grizzly.ssl.SSLEngineConfiguratorwhen configuring Grizzly client orSslEngineConfiguratorwhen configuring JDK client.Example configuration for JDK client: SslContextConfigurator sslContextConfigurator = new SslContextConfigurator(); sslContextConfigurator.setTrustStoreFile("..."); sslContextConfigurator.setTrustStorePassword("..."); sslContextConfigurator.setTrustStoreType("..."); sslContextConfigurator.setKeyStoreFile("..."); sslContextConfigurator.setKeyStorePassword("..."); sslContextConfigurator.setKeyStoreType("..."); SslEngineConfigurator sslEngineConfigurator = new SslEngineConfigurator(sslContextConfigurator, true, false, false); client.getProperties().put(ClientManager.SSL_ENGINE_CONFIGURATOR, sslEngineConfigurator);- See Also:
 
- 
WLS_PROXY_HOST- See Also:
 
- 
WLS_PROXY_PORT- See Also:
 
- 
WLS_PROXY_USERNAME- See Also:
 
- 
WLS_PROXY_PASSWORD- See Also:
 
- 
WLS_SSL_PROTOCOLS_PROPERTY- See Also:
 
- 
WLS_SSL_TRUSTSTORE_PROPERTY- See Also:
 
- 
WLS_SSL_TRUSTSTORE_PWD_PROPERTY- See Also:
 
- 
WLS_MAX_THREADS- See Also:
 
- 
WLS_IGNORE_HOSTNAME_VERIFICATION- See Also:
 
- 
WLS_HOSTNAME_VERIFIER_CLASS- See Also:
 
 
- 
- 
Constructor Details- 
ClientManagerpublic ClientManager()Create newClientManagerinstance.Uses CONTAINER_PROVIDER_CLASSNAMEas container implementation, thus relevant module needs to be on classpath. Setting different container is possible viacreateClient(String)}.- See Also:
 
 
- 
- 
Method Details- 
createClientCreate newClientManagerinstance.Uses CONTAINER_PROVIDER_CLASSNAMEas container implementation, thus relevant module needs to be on classpath. Setting different container is possible viacreateClient(String).- Returns:
- created client manager.
- See Also:
 
- 
createClientCreate new ClientManager instance on top of providedWebSocketContainerinstance.Uses CONTAINER_PROVIDER_CLASSNAMEas container implementation, thus relevant module needs to be on classpath. Setting different container is possible viacreateClient(String).- Parameters:
- webSocketContainer- websocket container.
- Returns:
- created client manager.
- See Also:
 
- 
createClientCreate new ClientManager instance.- Parameters:
- containerProviderClassName- classname of container provider. It will be loaded using context class loader.
- Returns:
- new ClientManager instance.
 
- 
createClientpublic static ClientManager createClient(String containerProviderClassName, WebSocketContainer webSocketContainer) Create new ClientManager instance on top of providedWebSocketContainerinstance.- Parameters:
- containerProviderClassName- classname of container provider. It will be loaded using context class loader.
- webSocketContainer- websocket container.
- Returns:
- new ClientManager instance.
 
- 
connectToServerpublic Session connectToServer(Class annotatedEndpointClass, URI path) throws DeploymentException, IOException Description copied from interface:WebSocketContainerConnect the supplied annotated endpoint to its server. The supplied object must be a class decorated with the class levelClientEndpointannotation. 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.- Specified by:
- connectToServerin interface- WebSocketContainer
- Parameters:
- annotatedEndpointClass- the annotated websocket client endpoint.
- path- the complete path to the server endpoint.
- Returns:
- the Session created if the connection is successful.
- Throws:
- 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.
 
- 
connectToServerpublic Session connectToServer(Class<? extends Endpoint> endpointClass, ClientEndpointConfig cec, URI path) throws DeploymentException, IOException Description copied from interface:WebSocketContainerConnect 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.- Specified by:
- connectToServerin interface- WebSocketContainer
- Parameters:
- endpointClass- the programmatic client endpoint class- Endpoint.
- cec- the configuration used to configure the programmatic endpoint.
- path- the complete path to the server endpoint.
- Returns:
- the Session created if the connection is successful.
- Throws:
- 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
 
- 
connectToServerpublic Session connectToServer(Endpoint endpointInstance, ClientEndpointConfig cec, URI path) throws DeploymentException, IOException Description copied from interface:WebSocketContainerConnect 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, useWebSocketContainer.connectToServer(java.lang.Class, jakarta.websocket.ClientEndpointConfig, java.net.URI)instead.- Specified by:
- connectToServerin interface- WebSocketContainer
- Parameters:
- endpointInstance- the programmatic client endpoint instance- Endpoint.
- cec- the configuration used to configure the programmatic endpoint.
- path- the complete path to the server endpoint.
- Returns:
- the Session created if the connection is successful.
- Throws:
- 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
 
- 
connectToServerDescription copied from interface:WebSocketContainerConnect the supplied annotated endpoint instance to its server. The supplied object must be a class decorated with the class levelClientEndpointannotation. 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, useWebSocketContainer.connectToServer(java.lang.Class, java.net.URI)instead.- Specified by:
- connectToServerin interface- WebSocketContainer
- Parameters:
- obj- the annotated websocket client endpoint instance.
- path- the complete path to the server endpoint.
- Returns:
- the Session created if the connection is successful.
- Throws:
- 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.
 
- 
asyncConnectToServerpublic Future<Session> asyncConnectToServer(Class<?> annotatedEndpointClass, URI path) throws DeploymentException Non-blocking version ofWebSocketContainer.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. - Parameters:
- annotatedEndpointClass- the annotated websocket client endpoint.
- path- the complete path to the server endpoint.
- Returns:
- Future for the Session created if the connection is successful.
- Throws:
- DeploymentException- if the class is not a valid annotated endpoint class.
 
- 
asyncConnectToServerpublic Future<Session> asyncConnectToServer(Class<? extends Endpoint> endpointClass, ClientEndpointConfig cec, URI path) throws DeploymentException Non-blocking version ofWebSocketContainer.connectToServer(Class, jakarta.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. - Parameters:
- endpointClass- the programmatic client endpoint class- Endpoint.
- cec- the configuration used to configure the programmatic endpoint.
- path- the complete path to the server endpoint.
- Returns:
- the Session created if the connection is successful.
- Throws:
- DeploymentException- if the configuration is not valid
- See Also:
 
- 
asyncConnectToServerpublic Future<Session> asyncConnectToServer(Endpoint endpointInstance, ClientEndpointConfig cec, URI path) throws DeploymentException Non-blocking version ofWebSocketContainer.connectToServer(jakarta.websocket.Endpoint, jakarta.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. - Parameters:
- endpointInstance- the programmatic client endpoint instance- Endpoint.
- cec- the configuration used to configure the programmatic endpoint.
- path- the complete path to the server endpoint.
- Returns:
- the Session created if the connection is successful.
- Throws:
- DeploymentException- if the configuration is not valid
- See Also:
 
- 
asyncConnectToServerNon-blocking version ofWebSocketContainer.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. - Parameters:
- obj- the annotated websocket client endpoint instance.
- path- the complete path to the server endpoint.
- Returns:
- the Session created if the connection is successful.
- Throws:
- DeploymentException- if the annotated endpoint instance is not valid.
- See Also:
 
- 
getDefaultMaxBinaryMessageBufferSizepublic int getDefaultMaxBinaryMessageBufferSize()Description copied from interface:WebSocketContainerReturns the default maximum size of incoming binary message that this container will buffer. This default may be overridden on a per session basis usingSession.setMaxBinaryMessageBufferSize(int)- Specified by:
- getDefaultMaxBinaryMessageBufferSizein interface- WebSocketContainer
- Returns:
- the maximum size of incoming binary message in number of bytes.
 
- 
setDefaultMaxBinaryMessageBufferSizepublic void setDefaultMaxBinaryMessageBufferSize(int i) Description copied from interface:WebSocketContainerSets the default maximum size of incoming binary message that this container will buffer.- Specified by:
- setDefaultMaxBinaryMessageBufferSizein interface- WebSocketContainer
- Parameters:
- i- the maximum size of binary message in number of bytes.
 
- 
getDefaultMaxTextMessageBufferSizepublic int getDefaultMaxTextMessageBufferSize()Description copied from interface:WebSocketContainerReturns the default maximum size of incoming text message that this container will buffer. This default may be overridden on a per session basis usingSession.setMaxTextMessageBufferSize(int)- Specified by:
- getDefaultMaxTextMessageBufferSizein interface- WebSocketContainer
- Returns:
- the maximum size of incoming text message in number of bytes.
 
- 
setDefaultMaxTextMessageBufferSizepublic void setDefaultMaxTextMessageBufferSize(int i) Description copied from interface:WebSocketContainerSets the maximum size of incoming text message that this container will buffer.- Specified by:
- setDefaultMaxTextMessageBufferSizein interface- WebSocketContainer
- Parameters:
- i- the maximum size of text message in number of bytes.
 
- 
getInstalledExtensionsDescription copied from interface:WebSocketContainerReturn the set of Extensions installed in the container.- Specified by:
- getInstalledExtensionsin interface- WebSocketContainer
- Returns:
- the set of extensions.
 
- 
getDefaultAsyncSendTimeoutpublic long getDefaultAsyncSendTimeout()Description copied from interface:WebSocketContainerReturn the number of milliseconds the implementation will timeout attempting to send a websocket message for all RemoteEndpoints associated with this container. A zero or negative value indicates the implementation will not timeout attempting to send a websocket message asynchronously. Note this default may be overridden in each RemoteEndpoint.- Specified by:
- getDefaultAsyncSendTimeoutin interface- WebSocketContainer
- Returns:
- the timeout time in milliseconds.
 
- 
setAsyncSendTimeoutpublic void setAsyncSendTimeout(long timeoutmillis) Description copied from interface:WebSocketContainerSets the number of milliseconds the implementation will timeout attempting to send a websocket message for all RemoteEndpoints associated with this container. A zero or negative value indicates the implementation will not timeout attempting to send a websocket message asynchronously. Note this default may be overridden in each RemoteEndpoint.- Specified by:
- setAsyncSendTimeoutin interface- WebSocketContainer
- Parameters:
- timeoutmillis- the timeout in milliseconds; use zero or negative value for no timeout
 
- 
getDefaultMaxSessionIdleTimeoutpublic long getDefaultMaxSessionIdleTimeout()Description copied from interface:WebSocketContainerReturn 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 zero or negative indicates the sessions will never timeout due to inactivity. The value may be overridden on a per session basis usingSession.setMaxIdleTimeout(long)- Specified by:
- getDefaultMaxSessionIdleTimeoutin interface- WebSocketContainer
- Returns:
- the default number of milliseconds after which an idle session in this container will be closed
 
- 
setDefaultMaxSessionIdleTimeoutpublic void setDefaultMaxSessionIdleTimeout(long defaultMaxSessionIdleTimeout) Description copied from interface:WebSocketContainerSets 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 zero or negative indicates the sessions will never timeout due to inactivity. The value may be overridden on a per session basis usingSession.setMaxIdleTimeout(long)- Specified by:
- setDefaultMaxSessionIdleTimeoutin interface- WebSocketContainer
- Parameters:
- defaultMaxSessionIdleTimeout- the maximum time in milliseconds; use zero or negative value for no timeout
 
- 
getPropertiesContainer properties.Used to set container specific configuration as SSL truststore and keystore, HTTP Proxy configuration and maximum incoming buffer size. These properties cannot be shared among various containers due to constraints in WebSocket API, so if you need to have multiple configurations, you will need to create multiple ClientManager instances or synchronize connectToServer method invocations. - Specified by:
- getPropertiesin class- BaseContainer
- Returns:
- map containing container properties.
- See Also:
 
 
- 
ClientProperties.HANDSHAKE_TIMEOUT.