Class WsClientEndpointFactoryBase

java.lang.Object
io.helidon.webclient.websocket.WsClientEndpointFactoryBase

@Contract public abstract class WsClientEndpointFactoryBase extends Object
This class is intended for generated code, and we do not expect this to be used directly by users.

For each declarative WebSocket client a factory is generated to allow connecting to the remote server(s). The factory is named by the endpoint class + "Factory" suffix.

In case there are path parameters in the configured Http.Path, they can either be provided in a map in connect(java.util.Map), or a method will be generated with all path parameters typed according to usage in the endpoint, or as Strings if not used. The generated method name is also connect.

  • Constructor Details

    • WsClientEndpointFactoryBase

      protected WsClientEndpointFactoryBase(Config config, String uri, String path, Set<String> pathParamNames)
      Create a new factory.
      Parameters:
      config - configuration (root) to use to set this factory up
      uri - base URI of this endpoint (in declarative, this would be the WebSocketClient.Endpoint.value())
      path - HTTP path, may contain path parameters (in declarative, this would be the Http.Path.value()
      pathParamNames - names of path parameters present in path, to avoid runtime parsing
  • Method Details

    • connect

      public void connect(Map<String,String> pathParameters)
      Connect to the WebSocket endpoint.
      Parameters:
      pathParameters - if the configured path has path parameters, these must be provided in the map
    • connect

      public void connect(WsClient wsClient, Map<String,String> pathParameters)
      Connect to the WebSocket endpoint using a custom client.
      Parameters:
      wsClient - client to use
      pathParameters - if the configured path has path parameters, these must be provided in the map
    • client

      public abstract WsClient client()
      The client used by this factory. This may be from service registry, or a new client. A custom client can be specified by calling connect(WsClient, java.util.Map), or in generated factories a method that has typed path parameters.
      Returns:
      WebSocket client used by this factory
    • pathParameterNames

      public Set<String> pathParameterNames()
      Path parameter names configured in the Http.Path.
      Returns:
      path parameter names
    • doConnect

      protected abstract void doConnect(WsClient wsClient, Map<String,String> pathParameters)
      Implement this method to correctly type path parameters provided by a user. The implementation is expected to call doConnect(WsClient, java.util.Map, java.util.function.Supplier).
      Parameters:
      wsClient - client to use
      pathParameters - provided path parameters, already validate that they contain all path parameters
    • doConnect

      protected void doConnect(WsClient client, Map<String,String> pathParameters, Supplier<WsListener> listener)
      Connects using the provided client. If the client has a base URI specified, uri is ignored, and only HTTP path will be used.
      Parameters:
      client - client to use
      pathParameters - path parameter map
      listener - listener supplier