Class JdkHttpRestClient.Builder
- All Implemented Interfaces:
ExecutorServiceAccessor.ExecutorServiceBuilder<JdkHttpRestClient.Builder>, TrustStoreDescriptorAccessor.TrustStoreDescriptorBuilder<JdkHttpRestClient.Builder>, BaseUrlAccessor.BaseUrlBuilder<JdkHttpRestClient.Builder>, HttpClientContext.Builder<JdkHttpRestClient.Builder>
- Enclosing class:
JdkHttpRestClient
Builder for constructing JdkHttpRestClient instances using a
fluent and strongly typed configuration API.
The builder internally delegates to HttpClientOptions.Builder and
exposes the most commonly used HTTP client configuration aspects,
including:
- base URL configuration
- HTTPS trust store configuration
- custom
ExecutorServiceintegration
The configured base URL acts as the canonical root URL for relative
request locators issued by the JdkHttpRestClient. Relative
request URLs are resolved against this configured base URL during request
execution.
HTTPS trust configuration may be provided through a
TrustStoreDescriptor, enabling custom trust stores for TLS
secured communication.
The resulting JdkHttpRestClient instance is constructed from the
accumulated HttpClientOptions.
Example:
JdkHttpRestClient theClient = JdkHttpRestClient.builder()
.withBaseUrl( "https://localhost:8443/api" )
.build();
The constructed client instance is not automatically opened. Invoke
JdkHttpRestClient.open() or JdkHttpRestClient.withOpen()
explicitly before issuing requests.
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Builds a new instance from the accumulated configuration.withBaseUrl(String aBaseUrl) withBaseUrl(URL aBaseURL) withBaseUrl(Url aBaseUrl) withExecutorService(ExecutorService aExecutorService) withTrustStoreDescriptor(TrustStoreDescriptor aTrustStoreDescriptor) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface BaseUrlAccessor.BaseUrlBuilder
withBaseUrl, withBaseUrl, withBaseUrl, withBaseUrl, withBaseUrl, withBaseUrl, withBaseUrl, withBaseUrl
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
withBaseUrl
- Specified by:
withBaseUrlin interfaceBaseUrlAccessor.BaseUrlBuilder<JdkHttpRestClient.Builder>- Throws:
MalformedURLException
-
withBaseUrl
- Specified by:
withBaseUrlin interfaceBaseUrlAccessor.BaseUrlBuilder<JdkHttpRestClient.Builder>
-
withBaseUrl
- Specified by:
withBaseUrlin interfaceBaseUrlAccessor.BaseUrlBuilder<JdkHttpRestClient.Builder>
-
withTrustStoreDescriptor
public JdkHttpRestClient.Builder withTrustStoreDescriptor(TrustStoreDescriptor aTrustStoreDescriptor) - Specified by:
withTrustStoreDescriptorin interfaceTrustStoreDescriptorAccessor.TrustStoreDescriptorBuilder<JdkHttpRestClient.Builder>
-
withExecutorService
- Specified by:
withExecutorServicein interfaceExecutorServiceAccessor.ExecutorServiceBuilder<JdkHttpRestClient.Builder>
-
build
Builds a new instance from the accumulated configuration.- Returns:
- The accordingly constructed instance.
-