Class JDKWSUtil

java.lang.Object
org.eclipse.net4j.ws.jdk.JDKWSUtil

public final class JDKWSUtil extends Object
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 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. A null context 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 the HttpClient overload to configure a proxy or authentication.
      Parameters:
      providerType - the unique factory type to register and select in the connector description
      sslContext - the TLS context to use, or null to 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. A null context selects the provider's shared default HTTP client. The HTTP client connect timeout remains ten seconds when a TLS context creates a client; options controls the WebSocket handshake, heartbeat, and complete-message limit.
      Parameters:
      providerType - the unique factory type to register and select in the connector description
      sslContext - the TLS context to use, or null for the provider's default HTTP client
      options - immutable per-provider connection options
      Returns:
      the configured message-connection provider factory
      Throws:
      NullPointerException - if options is null
    • 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 Eclipse IProxyService or 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 description
      client - the non-null caller-owned HTTP client shared by connections created through this factory
      webSocketConnectTimeout - 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 - if client or webSocketConnectTimeout is null
      IllegalArgumentException - if webSocketConnectTimeout is 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 description
      client - the non-null caller-owned HTTP client shared by connections created through this factory
      options - immutable per-provider connection options
      Returns:
      the configured message-connection provider factory
      Throws:
      NullPointerException - if client or options is null