Class SimpleClientFactoryAbstract<S extends Closeable>

java.lang.Object
io.clonecloudstore.common.quarkus.client.SimpleClientFactoryAbstract<S>
Type Parameters:
S - the type for the Rest Service as Quarkus definition
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
AccessorBucketApiFactory, AccessorBucketInternalApiFactory, ClientFactoryAbstract, OwnershipApiClientFactory, TopologyApiClientFactory

public abstract class SimpleClientFactoryAbstract<S extends Closeable> extends Object implements Closeable
The Abstract implementation for the Client Factory. Note that the implementation can use ApplicationScoped annotation. Use property quarkus.rest-client."org.acme.rest.client.ExtensionsService".url to setup the right URL for Quarkus service.
  • Field Details

  • Constructor Details

    • SimpleClientFactoryAbstract

      protected SimpleClientFactoryAbstract()
      Empty constructor
  • Method Details

    • getServiceClass

      protected abstract Class<?> getServiceClass()
      Shall be overridden
      Returns:
      the class of API Interface
    • prepare

      public SimpleClientFactoryAbstract<S> prepare(URI uri)
      Allows to change the target after initialization. This shall be called from Properties at runtime for each Factory (1 per destination). Not necessary if the configuration contains and if the factory is for only one target:
      quarkus.rest-client."org.acme.rest.client.ExtensionsService".url=https://hostname:port/api
    • prepare

      public SimpleClientFactoryAbstract<S> prepare(boolean tls, String hostname, int quarkusPort, String path)
      Allows to change the target after initialization. This shall be called from Properties at runtime for each Factory (1 per destination). Not necessary if the configuration contains and if the factory is for only one target:
      quarkus.rest-client."org.acme.rest.client.ExtensionsService".url=https://hostname:port/api
    • getVertx

      public io.vertx.mutiny.core.Vertx getVertx()
      Returns:
      the Vertx CDI instance
    • getUri

      public URI getUri()
      Returns:
      the URI as specified by tls, hostname and quarkusPort
    • close

      @PreDestroy public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • isTls

      public boolean isTls()
      Returns:
      True if TLS is required
    • getService

      protected S getService(URI uri)
      In general, implementation is: QuarkusRestClientBuilder.newBuilder().baseUri(uri).build(ServiceRest.class) where ServiceRest is your Java Interface of the Rest Service.
      Returns:
      the Rest Service associated
    • newClient

      public abstract SimpleClientAbstract<S> newClient()
      In general, implementation is simply: return new ClientImpl(this);
      Returns:
      the new Client with this associated factory
    • newClient

      public SimpleClientAbstract<S> newClient(URI uri)
      For Factory with multiple targets, to ensure correctness of URI
      Returns:
      the new Client with this associated factory for this URI