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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
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.protected abstract Class
<?> Shall be overriddengetUri()
io.vertx.mutiny.core.Vertx
getVertx()
boolean
isTls()
abstract SimpleClientAbstract
<S> In general, implementation is simply: return new ClientImpl(this);For Factory with multiple targets, to ensure correctness of URIAllows to change the target after initialization.Allows to change the target after initialization.
-
Field Details
-
DEFAULT_VALUE
- See Also:
-
-
Constructor Details
-
SimpleClientFactoryAbstract
protected SimpleClientFactoryAbstract()Empty constructor
-
-
Method Details
-
getServiceClass
Shall be overridden- Returns:
- the class of API Interface
-
prepare
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
- Returns:
- the URI as specified by tls, hostname and quarkusPort
-
close
@PreDestroy public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
isTls
public boolean isTls()- Returns:
- True if TLS is required
-
getService
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
In general, implementation is simply: return new ClientImpl(this);- Returns:
- the new Client with this associated factory
-
newClient
For Factory with multiple targets, to ensure correctness of URI- Returns:
- the new Client with this associated factory for this URI
-