Class ClientManager
- All Implemented Interfaces:
jakarta.websocket.WebSocketContainer
- Author:
- Stepan Kopriva, Pavel Bucek
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from class org.glassfish.tyrus.core.BaseContainer
org.glassfish.tyrus.core.BaseContainer.ShutDownCondition -
Field Summary
FieldsModifier 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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionFuture<jakarta.websocket.Session> asyncConnectToServer(jakarta.websocket.Endpoint endpointInstance, jakarta.websocket.ClientEndpointConfig cec, URI path) Non-blocking version ofWebSocketContainer.connectToServer(jakarta.websocket.Endpoint, jakarta.websocket.ClientEndpointConfig, java.net.URI).Future<jakarta.websocket.Session> asyncConnectToServer(Class<?> annotatedEndpointClass, URI path) Non-blocking version ofWebSocketContainer.connectToServer(Class, java.net.URI).Future<jakarta.websocket.Session> asyncConnectToServer(Class<? extends jakarta.websocket.Endpoint> endpointClass, jakarta.websocket.ClientEndpointConfig cec, URI path) Non-blocking version ofWebSocketContainer.connectToServer(Class, jakarta.websocket.ClientEndpointConfig, java.net.URI).Future<jakarta.websocket.Session> asyncConnectToServer(Object obj, URI path) Non-blocking version ofWebSocketContainer.connectToServer(Object, java.net.URI).jakarta.websocket.SessionconnectToServer(jakarta.websocket.Endpoint endpointInstance, jakarta.websocket.ClientEndpointConfig cec, URI path) jakarta.websocket.SessionconnectToServer(Class<? extends jakarta.websocket.Endpoint> endpointClass, jakarta.websocket.ClientEndpointConfig cec, URI path) jakarta.websocket.SessionconnectToServer(Class annotatedEndpointClass, URI path) jakarta.websocket.SessionconnectToServer(Object obj, URI path) static ClientManagerCreate newClientManagerinstance.static ClientManagercreateClient(jakarta.websocket.WebSocketContainer webSocketContainer) Create new ClientManager instance on top of providedWebSocketContainerinstance.static ClientManagercreateClient(String containerProviderClassName) Create new ClientManager instance.static ClientManagercreateClient(String containerProviderClassName, jakarta.websocket.WebSocketContainer webSocketContainer) Create new ClientManager instance on top of providedWebSocketContainerinstance.longintlongintSet<jakarta.websocket.Extension> Container properties.voidsetAsyncSendTimeout(long timeoutmillis) voidvoidsetDefaultMaxSessionIdleTimeout(long defaultMaxSessionIdleTimeout) voidMethods inherited from class org.glassfish.tyrus.core.BaseContainer
getExecutorService, getScheduledExecutorService, shutdown, shutdown
-
Field Details
-
HANDSHAKE_TIMEOUT
Deprecated.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_HANDLER
Deprecated.please useClientProperties.RECONNECT_HANDLER.Property usable ingetProperties().Value must be
ClientManager.ReconnectHandlerinstance.- See Also:
-
PROXY_URI
Deprecated.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_HEADERS
Deprecated.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_CONFIGURATOR
Deprecated.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
-
ClientManager
public 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
-
createClient
Create 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:
-
createClient
Create 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:
-
createClient
Create new ClientManager instance.- Parameters:
containerProviderClassName- classname of container provider. It will be loaded using context class loader.- Returns:
- new ClientManager instance.
-
createClient
public static ClientManager createClient(String containerProviderClassName, jakarta.websocket.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.
-
connectToServer
public jakarta.websocket.Session connectToServer(Class annotatedEndpointClass, URI path) throws jakarta.websocket.DeploymentException, IOException - Specified by:
connectToServerin interfacejakarta.websocket.WebSocketContainer- Throws:
jakarta.websocket.DeploymentExceptionIOException
-
connectToServer
public jakarta.websocket.Session connectToServer(Class<? extends jakarta.websocket.Endpoint> endpointClass, jakarta.websocket.ClientEndpointConfig cec, URI path) throws jakarta.websocket.DeploymentException, IOException - Specified by:
connectToServerin interfacejakarta.websocket.WebSocketContainer- Throws:
jakarta.websocket.DeploymentExceptionIOException
-
connectToServer
public jakarta.websocket.Session connectToServer(jakarta.websocket.Endpoint endpointInstance, jakarta.websocket.ClientEndpointConfig cec, URI path) throws jakarta.websocket.DeploymentException, IOException - Specified by:
connectToServerin interfacejakarta.websocket.WebSocketContainer- Throws:
jakarta.websocket.DeploymentExceptionIOException
-
connectToServer
public jakarta.websocket.Session connectToServer(Object obj, URI path) throws jakarta.websocket.DeploymentException, IOException - Specified by:
connectToServerin interfacejakarta.websocket.WebSocketContainer- Throws:
jakarta.websocket.DeploymentExceptionIOException
-
asyncConnectToServer
public Future<jakarta.websocket.Session> asyncConnectToServer(Class<?> annotatedEndpointClass, URI path) throws jakarta.websocket.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:
jakarta.websocket.DeploymentException- if the class is not a valid annotated endpoint class.
-
asyncConnectToServer
public Future<jakarta.websocket.Session> asyncConnectToServer(Class<? extends jakarta.websocket.Endpoint> endpointClass, jakarta.websocket.ClientEndpointConfig cec, URI path) throws jakarta.websocket.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 classEndpoint.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:
jakarta.websocket.DeploymentException- if the configuration is not valid- See Also:
-
asyncConnectToServer
public Future<jakarta.websocket.Session> asyncConnectToServer(jakarta.websocket.Endpoint endpointInstance, jakarta.websocket.ClientEndpointConfig cec, URI path) throws jakarta.websocket.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 instanceEndpoint.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:
jakarta.websocket.DeploymentException- if the configuration is not valid- See Also:
-
asyncConnectToServer
public Future<jakarta.websocket.Session> asyncConnectToServer(Object obj, URI path) throws jakarta.websocket.DeploymentException Non-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:
jakarta.websocket.DeploymentException- if the annotated endpoint instance is not valid.- See Also:
-
getDefaultMaxBinaryMessageBufferSize
public int getDefaultMaxBinaryMessageBufferSize()- Specified by:
getDefaultMaxBinaryMessageBufferSizein interfacejakarta.websocket.WebSocketContainer
-
setDefaultMaxBinaryMessageBufferSize
public void setDefaultMaxBinaryMessageBufferSize(int i) - Specified by:
setDefaultMaxBinaryMessageBufferSizein interfacejakarta.websocket.WebSocketContainer
-
getDefaultMaxTextMessageBufferSize
public int getDefaultMaxTextMessageBufferSize()- Specified by:
getDefaultMaxTextMessageBufferSizein interfacejakarta.websocket.WebSocketContainer
-
setDefaultMaxTextMessageBufferSize
public void setDefaultMaxTextMessageBufferSize(int i) - Specified by:
setDefaultMaxTextMessageBufferSizein interfacejakarta.websocket.WebSocketContainer
-
getInstalledExtensions
- Specified by:
getInstalledExtensionsin interfacejakarta.websocket.WebSocketContainer
-
getDefaultAsyncSendTimeout
public long getDefaultAsyncSendTimeout()- Specified by:
getDefaultAsyncSendTimeoutin interfacejakarta.websocket.WebSocketContainer
-
setAsyncSendTimeout
public void setAsyncSendTimeout(long timeoutmillis) - Specified by:
setAsyncSendTimeoutin interfacejakarta.websocket.WebSocketContainer
-
getDefaultMaxSessionIdleTimeout
public long getDefaultMaxSessionIdleTimeout()- Specified by:
getDefaultMaxSessionIdleTimeoutin interfacejakarta.websocket.WebSocketContainer
-
setDefaultMaxSessionIdleTimeout
public void setDefaultMaxSessionIdleTimeout(long defaultMaxSessionIdleTimeout) - Specified by:
setDefaultMaxSessionIdleTimeoutin interfacejakarta.websocket.WebSocketContainer
-
getProperties
Container 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 classorg.glassfish.tyrus.core.BaseContainer- Returns:
- map containing container properties.
- See Also:
-
ClientProperties.HANDSHAKE_TIMEOUT.