public class ClientManager extends BaseContainer implements javax.websocket.WebSocketContainer
Modifier and Type | Class and Description |
---|---|
static class |
ClientManager.ReconnectHandler
Reconnect handler.
|
BaseContainer.ShutDownCondition
Modifier and Type | Field and Description |
---|---|
static String |
HANDSHAKE_TIMEOUT
Deprecated.
please use
ClientProperties.HANDSHAKE_TIMEOUT . |
static String |
PROXY_HEADERS
Deprecated.
please use
ClientProperties.PROXY_HEADERS . |
static String |
PROXY_URI
Deprecated.
please use
ClientProperties.PROXY_URI . |
static String |
RECONNECT_HANDLER
Deprecated.
please use
ClientProperties.RECONNECT_HANDLER . |
static String |
SSL_ENGINE_CONFIGURATOR
Deprecated.
please use
ClientProperties.SSL_ENGINE_CONFIGURATOR . |
static String |
WLS_HOSTNAME_VERIFIER_CLASS |
static String |
WLS_IGNORE_HOSTNAME_VERIFICATION |
static String |
WLS_MAX_THREADS |
static String |
WLS_PROXY_HOST |
static String |
WLS_PROXY_PASSWORD |
static String |
WLS_PROXY_PORT |
static String |
WLS_PROXY_USERNAME |
static String |
WLS_SSL_PROTOCOLS_PROPERTY |
static String |
WLS_SSL_TRUSTSTORE_PROPERTY |
static String |
WLS_SSL_TRUSTSTORE_PWD_PROPERTY |
Constructor and Description |
---|
ClientManager()
Create new
ClientManager instance. |
Modifier and Type | Method and Description |
---|---|
Future<javax.websocket.Session> |
asyncConnectToServer(Class<?> annotatedEndpointClass,
URI path)
Non-blocking version of
WebSocketContainer.connectToServer(Class, java.net.URI) . |
Future<javax.websocket.Session> |
asyncConnectToServer(Class<? extends javax.websocket.Endpoint> endpointClass,
javax.websocket.ClientEndpointConfig cec,
URI path)
Non-blocking version of
WebSocketContainer.connectToServer(Class, javax.websocket.ClientEndpointConfig,
java.net.URI) . |
Future<javax.websocket.Session> |
asyncConnectToServer(javax.websocket.Endpoint endpointInstance,
javax.websocket.ClientEndpointConfig cec,
URI path)
Non-blocking version of
WebSocketContainer.connectToServer(javax.websocket.Endpoint,
javax.websocket.ClientEndpointConfig, java.net.URI) . |
Future<javax.websocket.Session> |
asyncConnectToServer(Object obj,
URI path)
Non-blocking version of
WebSocketContainer.connectToServer(Object, java.net.URI) . |
javax.websocket.Session |
connectToServer(Class<? extends javax.websocket.Endpoint> endpointClass,
javax.websocket.ClientEndpointConfig cec,
URI path) |
javax.websocket.Session |
connectToServer(Class annotatedEndpointClass,
URI path) |
javax.websocket.Session |
connectToServer(javax.websocket.Endpoint endpointInstance,
javax.websocket.ClientEndpointConfig cec,
URI path) |
javax.websocket.Session |
connectToServer(Object obj,
URI path) |
static ClientManager |
createClient()
Create new
ClientManager instance. |
static ClientManager |
createClient(String containerProviderClassName)
Create new ClientManager instance.
|
static ClientManager |
createClient(String containerProviderClassName,
javax.websocket.WebSocketContainer webSocketContainer)
Create new ClientManager instance on top of provided
WebSocketContainer instance. |
static ClientManager |
createClient(javax.websocket.WebSocketContainer webSocketContainer)
Create new ClientManager instance on top of provided
WebSocketContainer instance. |
long |
getDefaultAsyncSendTimeout() |
int |
getDefaultMaxBinaryMessageBufferSize() |
long |
getDefaultMaxSessionIdleTimeout() |
int |
getDefaultMaxTextMessageBufferSize() |
Set<javax.websocket.Extension> |
getInstalledExtensions() |
Map<String,Object> |
getProperties()
Container properties.
|
void |
setAsyncSendTimeout(long timeoutmillis) |
void |
setDefaultMaxBinaryMessageBufferSize(int i) |
void |
setDefaultMaxSessionIdleTimeout(long defaultMaxSessionIdleTimeout) |
void |
setDefaultMaxTextMessageBufferSize(int i) |
getExecutorService, getScheduledExecutorService, shutdown, shutdown
public static final String HANDSHAKE_TIMEOUT
ClientProperties.HANDSHAKE_TIMEOUT
.getProperties()
.
Value must be int
and represents handshake timeout in milliseconds. Default value is 30000 (30 seconds).public static final String RECONNECT_HANDLER
ClientProperties.RECONNECT_HANDLER
.getProperties()
.
Value must be ClientManager.ReconnectHandler
instance.public static final String PROXY_URI
ClientProperties.PROXY_URI
.String
and represent proxy URI. Protocol part is currently ignored
but must be present (URI.URI(String)
is used for parsing).
client.getProperties().put(ClientManager.PROXY_URI, "http://my.proxy.com:80"); client.connectToServer(...);
EndpointConfig.getUserProperties()
,
Constant Field Valuespublic static final String PROXY_HEADERS
ClientProperties.PROXY_HEADERS
.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 HashMapPlease note that these headers will be used only when establishing proxy connection, for modifying WebSocket handshake headers, seeproxyHeaders = new HashMap (); proxyHeaders.put("Proxy-Authorization", "Basic " + Base64Utils.encodeToString("username:password".getBytes(Charset.forName("UTF-8")), false)); client.getProperties().put(GrizzlyClientSocket.PROXY_HEADERS, proxyHeaders); client.connectToServer(...);
ClientEndpointConfig.Configurator.beforeRequest(java.util.Map)
.EndpointConfig.getUserProperties()
,
Constant Field Valuespublic static final String SSL_ENGINE_CONFIGURATOR
ClientProperties.SSL_ENGINE_CONFIGURATOR
.getProperties()
as a key for SSL configuration.
Value is expected to be either org.glassfish.grizzly.ssl.SSLEngineConfigurator
when configuring Grizzly
client or SslEngineConfigurator
when 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);
public static final String WLS_PROXY_HOST
public static final String WLS_PROXY_PORT
public static final String WLS_PROXY_USERNAME
public static final String WLS_PROXY_PASSWORD
public static final String WLS_SSL_PROTOCOLS_PROPERTY
public static final String WLS_SSL_TRUSTSTORE_PROPERTY
public static final String WLS_SSL_TRUSTSTORE_PWD_PROPERTY
public static final String WLS_MAX_THREADS
public static final String WLS_IGNORE_HOSTNAME_VERIFICATION
public static final String WLS_HOSTNAME_VERIFIER_CLASS
public ClientManager()
ClientManager
instance.
Uses CONTAINER_PROVIDER_CLASSNAME
as container implementation, thus relevant module needs
to be on classpath. Setting different container is possible via createClient(String)
}.createClient(String)
public static ClientManager createClient()
ClientManager
instance.
Uses CONTAINER_PROVIDER_CLASSNAME
as container implementation, thus relevant module needs
to be on classpath. Setting different container is possible via createClient(String)
.createClient(String)
public static ClientManager createClient(javax.websocket.WebSocketContainer webSocketContainer)
WebSocketContainer
instance.
Uses CONTAINER_PROVIDER_CLASSNAME
as container implementation, thus relevant module needs
to be on classpath. Setting different container is possible via createClient(String)
.createClient(String)
public static ClientManager createClient(String containerProviderClassName)
public static ClientManager createClient(String containerProviderClassName, javax.websocket.WebSocketContainer webSocketContainer)
WebSocketContainer
instance.public javax.websocket.Session connectToServer(Class annotatedEndpointClass, URI path) throws javax.websocket.DeploymentException, IOException
connectToServer
in interface javax.websocket.WebSocketContainer
javax.websocket.DeploymentException
IOException
public javax.websocket.Session connectToServer(Class<? extends javax.websocket.Endpoint> endpointClass, javax.websocket.ClientEndpointConfig cec, URI path) throws javax.websocket.DeploymentException, IOException
connectToServer
in interface javax.websocket.WebSocketContainer
javax.websocket.DeploymentException
IOException
public javax.websocket.Session connectToServer(javax.websocket.Endpoint endpointInstance, javax.websocket.ClientEndpointConfig cec, URI path) throws javax.websocket.DeploymentException, IOException
connectToServer
in interface javax.websocket.WebSocketContainer
javax.websocket.DeploymentException
IOException
public javax.websocket.Session connectToServer(Object obj, URI path) throws javax.websocket.DeploymentException, IOException
connectToServer
in interface javax.websocket.WebSocketContainer
javax.websocket.DeploymentException
IOException
public Future<javax.websocket.Session> asyncConnectToServer(Class<?> annotatedEndpointClass, URI path) throws javax.websocket.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.javax.websocket.DeploymentException
- if the class is not a valid annotated endpoint class.public Future<javax.websocket.Session> asyncConnectToServer(Class<? extends javax.websocket.Endpoint> endpointClass, javax.websocket.ClientEndpointConfig cec, URI path) throws javax.websocket.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.javax.websocket.DeploymentException
- if the configuration is not validWebSocketContainer.connectToServer(Class, javax.websocket.ClientEndpointConfig, java.net.URI)
public Future<javax.websocket.Session> asyncConnectToServer(javax.websocket.Endpoint endpointInstance, javax.websocket.ClientEndpointConfig cec, URI path) throws javax.websocket.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.javax.websocket.DeploymentException
- if the configuration is not validWebSocketContainer.connectToServer(javax.websocket.Endpoint, javax.websocket.ClientEndpointConfig,
java.net.URI)
public Future<javax.websocket.Session> asyncConnectToServer(Object obj, URI path) throws javax.websocket.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.javax.websocket.DeploymentException
- if the annotated endpoint instance is not valid.WebSocketContainer.connectToServer(Object, java.net.URI)
public int getDefaultMaxBinaryMessageBufferSize()
getDefaultMaxBinaryMessageBufferSize
in interface javax.websocket.WebSocketContainer
public void setDefaultMaxBinaryMessageBufferSize(int i)
setDefaultMaxBinaryMessageBufferSize
in interface javax.websocket.WebSocketContainer
public int getDefaultMaxTextMessageBufferSize()
getDefaultMaxTextMessageBufferSize
in interface javax.websocket.WebSocketContainer
public void setDefaultMaxTextMessageBufferSize(int i)
setDefaultMaxTextMessageBufferSize
in interface javax.websocket.WebSocketContainer
public Set<javax.websocket.Extension> getInstalledExtensions()
getInstalledExtensions
in interface javax.websocket.WebSocketContainer
public long getDefaultAsyncSendTimeout()
getDefaultAsyncSendTimeout
in interface javax.websocket.WebSocketContainer
public void setAsyncSendTimeout(long timeoutmillis)
setAsyncSendTimeout
in interface javax.websocket.WebSocketContainer
public long getDefaultMaxSessionIdleTimeout()
getDefaultMaxSessionIdleTimeout
in interface javax.websocket.WebSocketContainer
public void setDefaultMaxSessionIdleTimeout(long defaultMaxSessionIdleTimeout)
setDefaultMaxSessionIdleTimeout
in interface javax.websocket.WebSocketContainer
public Map<String,Object> getProperties()
ClientProperties
Copyright © 2012-2015, Oracle and/or its affiliates. All Rights Reserved. Use is subject to license terms.