public abstract class WebSocketFactory extends Object
WebSocketFactory
is an abstract class that can be used to create
WebSocket
s by specifying the end-point and the enabled protocols.
It may be extended to instantiate particular subclasses of WebSocket
and thus provide a general framework for the addition of public
WebSocket-level functionality.
Using WebSocketFactory
instance, application developers can set
WebSocketExtension.Parameter
s that will be inherited by all the
WebSocket
instances created from the factory. Application developers
can override the WebSocketExtension.Parameter
s at the individual
WebSocket
level too.
Modifier | Constructor and Description |
---|---|
protected |
WebSocketFactory() |
Modifier and Type | Method and Description |
---|---|
abstract WebSocket |
createWebSocket(URI location)
Creates a
WebSocket to establish a full-duplex connection to the
target location. |
abstract WebSocket |
createWebSocket(URI location,
String... protocols)
Creates a
WebSocket to establish a full-duplex connection to the
target location with one of the specified protocols on a supported
WebSocket provider. |
static WebSocketFactory |
createWebSocketFactory()
Creates and returns a new instance of the default implementation of the
WebSocketFactory . |
abstract ChallengeHandler |
getDefaultChallengeHandler()
Gets the default
ChallengeHandler that is used during
authentication both at the connect-time as well as at subsequent
revalidation-time that occurs at regular intervals. |
abstract int |
getDefaultConnectTimeout()
Gets the default connect timeout in milliseconds.
|
abstract Collection<String> |
getDefaultEnabledExtensions()
Gets the names of the default enabled extensions that will be inherited
by all the
WebSocket s created using this factory. |
abstract HttpRedirectPolicy |
getDefaultFollowRedirect()
Returns the default
HttpRedirectOption that was specified at
on the factory. |
abstract <T> T |
getDefaultParameter(WebSocketExtension.Parameter<T> parameter)
Returns the default value of the specified
WebSocketExtension.Parameter . |
abstract Collection<String> |
getSupportedExtensions()
Returns the names of supported extensions that have been discovered.
|
abstract void |
setDefaultChallengeHandler(ChallengeHandler challengeHandler)
Sets the default
ChallengeHandler that is used during
authentication both at the connect-time as well as at subsequent
revalidation-time that occurs at regular intervals. |
abstract void |
setDefaultConnectTimeout(int connectTimeout)
Sets the default connect timeout in milliseconds.
|
abstract void |
setDefaultEnabledExtensions(Collection<String> extensions)
Registers the names of all the default enabled extensions to be inherited
by all the
WebSocket s created using this factory. |
abstract void |
setDefaultFollowRedirect(HttpRedirectPolicy redirectOption)
Sets the default
HttpRedirectOption that is to be inherited by
all the WebSocket s created using this factory instance. |
abstract <T> void |
setDefaultParameter(WebSocketExtension.Parameter<T> parameter,
T value)
Sets the default value of the specified
WebSocketExtension.Parameter
that will be inherited by all the WebSocket s that are created
using this factory instance. |
public static WebSocketFactory createWebSocketFactory()
WebSocketFactory
.public abstract WebSocket createWebSocket(URI location) throws URISyntaxException
WebSocket
to establish a full-duplex connection to the
target location.
The default extension parameters that were set on the
WebSocketFactory
prior to this call are inherited by the newly
newly created WebSocket
instance.
location
- URI of the WebSocket service for the connectionURISyntaxException
public abstract WebSocket createWebSocket(URI location, String... protocols) throws URISyntaxException
WebSocket
to establish a full-duplex connection to the
target location with one of the specified protocols on a supported
WebSocket provider.
The default extension parameters that were set on the
WebSocketFactory
prior to this call are inherited by the newly
newly created WebSocket
instance.
location
- URI of the WebSocket service for the connectionprotocols
- protocols to be negotiated over the WebSocket, or
null for any protocolURISyntaxException
public abstract ChallengeHandler getDefaultChallengeHandler()
ChallengeHandler
that is used during
authentication both at the connect-time as well as at subsequent
revalidation-time that occurs at regular intervals.public abstract int getDefaultConnectTimeout()
public abstract Collection<String> getDefaultEnabledExtensions()
WebSocket
s created using this factory. These
extensions are negotiated between the client and the server during the
WebSocket handshake only if all the required parameters belonging to the
extension have been set as enabled parameters. An empty Collection is
returned if no extensions have been enabled for this factory.public abstract HttpRedirectPolicy getDefaultFollowRedirect()
HttpRedirectOption
that was specified at
on the factory. The default options is HttpRedirectOption.ALWAYS
.public abstract <T> T getDefaultParameter(WebSocketExtension.Parameter<T> parameter)
WebSocketExtension.Parameter
.T
- parameter typeparameter
- extension parameterpublic abstract Collection<String> getSupportedExtensions()
public abstract void setDefaultChallengeHandler(ChallengeHandler challengeHandler)
ChallengeHandler
that is used during
authentication both at the connect-time as well as at subsequent
revalidation-time that occurs at regular intervals. All the
WebSocket
s created using this factory will inherit the default
ChallengeHandler.challengeHandler
- default ChallengeHandlerpublic abstract void setDefaultConnectTimeout(int connectTimeout)
connectTimeout
- timeout value in millisecondsIllegalArgumentException
- if connectTimeout is negativepublic abstract void setDefaultEnabledExtensions(Collection<String> extensions)
WebSocket
s created using this factory. The extensions
will be negotiated between the client and the server during the WebSocket
handshake if all the required parameters belonging to the extension have
been set. The default enabled extensions should be a subset of the
supported extensions.
If an enabled extension is not in the list of supported extensions, then IllegalStateException is thrown.
extensions
- list of extensions to be inherited by all the
WebSockets created using this factoryIllegalStateException
- if an extension is not in the list of the
supported extensions.public abstract void setDefaultFollowRedirect(HttpRedirectPolicy redirectOption)
HttpRedirectOption
that is to be inherited by
all the WebSocket
s created using this factory instance.option
- HttpRedirectOptionpublic abstract <T> void setDefaultParameter(WebSocketExtension.Parameter<T> parameter, T value)
WebSocketExtension.Parameter
that will be inherited by all the WebSocket
s that are created
using this factory instance. WebSocket
s that were created before
setting the WebSocketExtension.Parameter
using this API will not
be able to inherit the default value of the parameter.T
- parameter typeparameter
- extension parameter whose default value is to be setvalue
- default value of type Copyright © 2015. All Rights Reserved.