Class JDKWSUtil
java.lang.Object
org.eclipse.net4j.ws.jdk.JDKWSUtil
Creates configured JDK WebSocket provider factories without registering them.
A registered factory may be shared by multiple connectors; each call to its create method produces a
connection with independent runtime state. The overloads below determine whether those connections share the JDK
default HTTP client, a client configured from an SSLContext, or a caller-supplied HttpClient.
- Since:
- 2.0
- Author:
- Eike Stepper
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.eclipse.net4j.util.factory.IFactorycreateMessageConnectionFactory(String providerType, HttpClient client, Duration webSocketConnectTimeout) Creates a JDK WebSocket message-connection factory that shares the supplied HTTP client across the connections it creates and applies the supplied timeout to each WebSocket opening handshake.static org.eclipse.net4j.util.factory.IFactorycreateMessageConnectionFactory(String providerType, HttpClient client, JDKWSOptions options) Creates a JDK WebSocket provider that shares the supplied caller-owned HTTP client and applies the supplied immutable options to every connection created by the factory.static org.eclipse.net4j.util.factory.IFactorycreateMessageConnectionFactory(String providerType, SSLContext sslContext) Creates a JDK WebSocket message-connection factory that uses the given TLS context for secure WebSocket connections.static org.eclipse.net4j.util.factory.IFactorycreateMessageConnectionFactory(String providerType, SSLContext sslContext, JDKWSOptions options) Creates a JDK WebSocket provider using the supplied TLS context and immutable connection options.
-
Method Details
-
createMessageConnectionFactory
public static org.eclipse.net4j.util.factory.IFactory createMessageConnectionFactory(String providerType, SSLContext sslContext) Creates a JDK WebSocket message-connection factory that uses the given TLS context for secure WebSocket connections. Register the returned factory in the client container and select its type in the WS or WSS connector description. For a non-null context, this factory builds one HTTP client and shares it across the connections it creates; the JDK's normal certificate and hostname verification remain enabled. Anullcontext selects the provider's shared default HTTP client. Both paths use a ten-second HTTP connection timeout and a separate ten-second WebSocket opening-handshake timeout. Use theHttpClientoverload to configure a proxy or authentication.- Parameters:
providerType- the unique factory type to register and select in the connector descriptionsslContext- the TLS context to use, ornullto use the provider's shared Provider-default HTTP client- Returns:
- the configured message-connection provider factory
-
createMessageConnectionFactory
public static org.eclipse.net4j.util.factory.IFactory createMessageConnectionFactory(String providerType, SSLContext sslContext, JDKWSOptions options) Creates a JDK WebSocket provider using the supplied TLS context and immutable connection options. Anullcontext selects the provider's shared default HTTP client. The HTTP client connect timeout remains ten seconds when a TLS context creates a client;optionscontrols the WebSocket handshake, heartbeat, and complete-message limit.- Parameters:
providerType- the unique factory type to register and select in the connector descriptionsslContext- the TLS context to use, ornullfor the provider's default HTTP clientoptions- immutable per-provider connection options- Returns:
- the configured message-connection provider factory
- Throws:
NullPointerException- ifoptionsisnull
-
createMessageConnectionFactory
public static org.eclipse.net4j.util.factory.IFactory createMessageConnectionFactory(String providerType, HttpClient client, Duration webSocketConnectTimeout) Creates a JDK WebSocket message-connection factory that shares the supplied HTTP client across the connections it creates and applies the supplied timeout to each WebSocket opening handshake. The timeout is distinct from the HTTP client's connection timeout. Configure TLS, proxy selection, and any authenticator on the client before passing it here; this provider does not consult EclipseIProxyServiceor add proxy or authentication configuration. The factory and its connections do not own or close the client; the caller is responsible for its lifecycle. Register each independently configured factory under a distinct provider type to isolate its client configuration.- Parameters:
providerType- the unique factory type to register and select in the connector descriptionclient- the non-null caller-owned HTTP client shared by connections created through this factorywebSocketConnectTimeout- the positive maximum time to complete each WebSocket opening handshake, independent of the HTTP client's connection timeout- Returns:
- the configured message-connection provider factory
- Throws:
NullPointerException- ifclientorwebSocketConnectTimeoutisnullIllegalArgumentException- ifwebSocketConnectTimeoutis zero or negative
-
createMessageConnectionFactory
public static org.eclipse.net4j.util.factory.IFactory createMessageConnectionFactory(String providerType, HttpClient client, JDKWSOptions options) Creates a JDK WebSocket provider that shares the supplied caller-owned HTTP client and applies the supplied immutable options to every connection created by the factory.- Parameters:
providerType- the unique factory type to register and select in the connector descriptionclient- the non-null caller-owned HTTP client shared by connections created through this factoryoptions- immutable per-provider connection options- Returns:
- the configured message-connection provider factory
- Throws:
NullPointerException- ifclientoroptionsisnull
-