public interface RestClientBuilder
Invoking newBuilder() is intended to always create a new instance,
not use a cached version.
The RestClientBuilder is a Configurable class as defined
by JAX-RS. This allows a user to register providers, implementation specific
configuration.
Implementations are expected to implement this class and provide the instance
via the mechanism in RestClientBuilderResolver.instance().
| Modifier and Type | Method and Description |
|---|---|
default RestClientBuilder |
baseUri(java.net.URI uri)
Specifies the base URI to be used when making requests.
|
RestClientBuilder |
baseUrl(java.net.URL url)
Specifies the base URL to be used when making requests.
|
<T> T |
build(java.lang.Class<T> clazz)
Based on the configured RestClientBuilder, creates a new instance of the
given REST interface to invoke API calls against.
|
RestClientBuilder |
connectTimeout(long timeout,
java.util.concurrent.TimeUnit unit)
Set the connect timeout.
|
RestClientBuilder |
executorService(java.util.concurrent.ExecutorService executor)
Specifies the
ExecutorService to use when invoking
asynchronous Rest Client interface methods. |
RestClientBuilder |
followRedirects(boolean follow)
Specifies whether client built by this builder should follow HTTP
redirect responses (30x) or not.
|
RestClientBuilder |
hostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)
Set the hostname verifier to verify the endpoint's hostname
|
RestClientBuilder |
keyStore(java.security.KeyStore keyStore,
java.lang.String keystorePassword)
Set the client-side key store.
|
static RestClientBuilder |
newBuilder() |
RestClientBuilder |
proxyAddress(java.lang.String proxyHost,
int proxyPort)
Specifies the HTTP proxy hostname/IP address and port to use for requests from client instances.
|
RestClientBuilder |
queryParamStyle(QueryParamStyle style)
Specifies the URI formatting style to use when multiple query parameter values are passed to the client.
|
RestClientBuilder |
readTimeout(long timeout,
java.util.concurrent.TimeUnit unit)
Set the read timeout.
|
RestClientBuilder |
sslContext(javax.net.ssl.SSLContext sslContext)
Specifies the SSL context to use when creating secured transport connections to server endpoints
from web targets created by the client instance that is using this SSL context.
|
RestClientBuilder |
trustStore(java.security.KeyStore trustStore)
Set the client-side trust store.
|
static RestClientBuilder newBuilder()
RestClientBuilder baseUrl(java.net.URL url)
@Path("/api") at the interface level and a
url is given with
http://my-service:8080/service then all REST calls will be
invoked with a url of
http://my-service:8080/service/api in addition to any
@Path annotations included on the method.
Subsequent calls to this method will replace the previously specified
baseUri/baseUrl.url - the base Url for the service.default RestClientBuilder baseUri(java.net.URI uri)
@Path("/api") at the interface level and a
uri is given with
http://my-service:8080/service then all REST calls will be
invoked with a uri of
http://my-service:8080/service/api in addition to any
@Path annotations included on the method.
Subsequent calls to this method will replace the previously specified
baseUri/baseUrl.uri - the base URI for the service.java.lang.IllegalArgumentException - if the passed in URI is invalidRestClientBuilder connectTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Like JAX-RS's javax.ws.rs.client.ClientBuilder's
connectTimeout method, specifying a timeout of 0 represents
infinity, and negative values are not allowed.
If the client instance is injected via CDI and the "fully.qualified.InterfaceName/mp-rest/connectTimeout" property is set via MicroProfile Config, that property's value will override, the value specified to this method.
timeout - the maximum time to wait.unit - the time unit of the timeout argument.java.lang.IllegalArgumentException - - if the value of timeout is negative.RestClientBuilder readTimeout(long timeout, java.util.concurrent.TimeUnit unit)
Like JAX-RS's javax.ws.rs.client.ClientBuilder's
readTimeout method, specifying a timeout of 0 represents
infinity, and negative values are not allowed.
Also like the JAX-RS Client API, if the read timeout is reached, the
client interface method will throw a javax.ws.rs.ProcessingException.
If the client instance is injected via CDI and the "fully.qualified.InterfaceName/mp-rest/readTimeout" property is set via MicroProfile Config, that property's value will override, the value specified to this method.
timeout - the maximum time to wait.unit - the time unit of the timeout argument.java.lang.IllegalArgumentException - - if the value of timeout is negative.RestClientBuilder executorService(java.util.concurrent.ExecutorService executor)
ExecutorService to use when invoking
asynchronous Rest Client interface methods. By default, the executor
service used is determined by the MP Rest Client implementation runtime.executor - the executor service for the runtime to use when invoking
asynchronous Rest Client interface methods - must be non-null.java.lang.IllegalArgumentException - if the executor parameter is
null.RestClientBuilder sslContext(javax.net.ssl.SSLContext sslContext)
sslContext - the ssl contextjava.lang.NullPointerException - if the sslContext parameter is
null.RestClientBuilder trustStore(java.security.KeyStore trustStore)
trustStore - key storejava.lang.NullPointerException - if the trustStore parameter is
null.RestClientBuilder keyStore(java.security.KeyStore keyStore, java.lang.String keystorePassword)
keyStore - key storekeystorePassword - the password for the specified keyStorejava.lang.NullPointerException - if the keyStore parameter is
null.RestClientBuilder hostnameVerifier(javax.net.ssl.HostnameVerifier hostnameVerifier)
hostnameVerifier - the hostname verifierjava.lang.NullPointerException - if the hostnameVerifier parameter is
null.RestClientBuilder followRedirects(boolean follow)
follow - - true if the client should follow HTTP redirects, false if not.RestClientBuilder proxyAddress(java.lang.String proxyHost, int proxyPort)
proxyHost - - hostname or IP address of proxy server - must be non-nullproxyPort - - port of proxy serverjava.lang.IllegalArgumentException - if the proxyHost is null or the proxyPort is invalidRestClientBuilder queryParamStyle(QueryParamStyle style)
style - - the URI formatting style to use for multiple query parameter values<T> T build(java.lang.Class<T> clazz)
throws java.lang.IllegalStateException,
RestClientDefinitionException
T - the type of the interfaceclazz - the interface that defines REST API methods for usejava.lang.IllegalStateException - if not all pre-requisites are satisfied for
the builder, this exception may get thrown. For instance, if the base
URI/URL has not been set.RestClientDefinitionException - if the passed-in interface class is
invalid.