Class ApacheHttpClient5Accessor
HttpClient
s.- Since:
- 4.20.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.hc.client5.http.classic.HttpClient
Returns anHttpClient
independent of any destination.static org.apache.hc.client5.http.classic.HttpClient
getHttpClient
(Destination destination) Returns anHttpClient
for the givenDestination
.static org.apache.hc.client5.http.classic.HttpClient
getHttpClient
(HttpDestinationProperties destination) Returns anHttpClient
for the givenDestination
.static ApacheHttpClient5Cache
Configures theHttpClient5Cache
that is used by the#getHttpClient(String)
and#getHttpClient(Destination)
methods.static ApacheHttpClient5Factory
Returns theApacheHttpClient5Factory
that is used when creating instances ofHttpClient
within theApacheHttpClient5Accessor
.static void
setHttpClientCache
(ApacheHttpClient5Cache httpClientCache) Sets theApacheHttpClient5Cache
that is used when resolving cached instances ofHttpClient
within theApacheHttpClient5Accessor
.static void
setHttpClientFactory
(ApacheHttpClient5Factory httpClientFactory) Sets theApacheHttpClient5Factory
that is used when creating instances ofHttpClient
within theApacheHttpClient5Accessor
.static io.vavr.control.Try<org.apache.hc.client5.http.classic.HttpClient>
Returns anHttpClient
independent of any destination.static io.vavr.control.Try<org.apache.hc.client5.http.classic.HttpClient>
tryGetHttpClient
(Destination destination)
-
Method Details
-
setHttpClientFactory
Sets theApacheHttpClient5Factory
that is used when creating instances ofHttpClient
within theApacheHttpClient5Accessor
.CAUTION: This factory is accessed concurrently. Therefore, you have to make sure that you do not introduce any concurrency issues when changing the factory. Furthermore, be aware that setting a custom factory will affect all consumers of the
ApacheHttpClient5Accessor
within the application.- Parameters:
httpClientFactory
- The globalApacheHttpClient5Factory
instance to be used. Usenull
to reset the factory.
-
setHttpClientCache
Sets theApacheHttpClient5Cache
that is used when resolving cached instances ofHttpClient
within theApacheHttpClient5Accessor
.CAUTION: This cache is accessed concurrently. Therefore, you have to make sure that you do not introduce any concurrency issues when changing the cache. Furthermore, be aware that setting a custom cache will affect all consumers of the
ApacheHttpClient5Accessor
within the application.- Parameters:
httpClientCache
- The globalApacheHttpClient5Cache
instance to be used. Usenull
to reset the cache.
-
getHttpClient
@Nonnull public static org.apache.hc.client5.http.classic.HttpClient getHttpClient() throws HttpClientInstantiationExceptionReturns anHttpClient
independent of any destination.- Returns:
- An
HttpClient
independent of any destination. - Throws:
HttpClientInstantiationException
- If there is an issue creating theHttpClient
.
-
tryGetHttpClient
@Nonnull public static io.vavr.control.Try<org.apache.hc.client5.http.classic.HttpClient> tryGetHttpClient()Returns anHttpClient
independent of any destination.- Returns:
- An
HttpClient
independent of any destination.
-
getHttpClient
@Nonnull public static org.apache.hc.client5.http.classic.HttpClient getHttpClient(@Nonnull HttpDestinationProperties destination) throws DestinationAccessException, HttpClientInstantiationException Returns anHttpClient
for the givenDestination
. The instance may be cached.- Parameters:
destination
- The destination to get theHttpClient
for.- Returns:
- An
HttpClient
for the givenDestination
. The instance may be cached. - Throws:
DestinationAccessException
- If there is an issue accessing theDestination
.HttpClientInstantiationException
- If there is an issue creating theHttpClient
.
-
getHttpClient
@Nonnull public static org.apache.hc.client5.http.classic.HttpClient getHttpClient(@Nonnull Destination destination) throws DestinationAccessException, HttpClientInstantiationException Returns anHttpClient
for the givenDestination
. The instance may be cached.- Parameters:
destination
- The destination to get theHttpClient
for.- Returns:
- An
HttpClient
for the givenDestination
. The instance may be cached. - Throws:
DestinationAccessException
- If there is an issue accessing theDestination
.HttpClientInstantiationException
- If there is an issue creating theHttpClient
.
-
tryGetHttpClient
@Nonnull public static io.vavr.control.Try<org.apache.hc.client5.http.classic.HttpClient> tryGetHttpClient(@Nonnull Destination destination) - Parameters:
destination
- The destination to get theHttpClient
for.- Returns:
- A
Try
of anHttpClient
for the givenDestination
. The instance may be cached.
-
getHttpClientCache
Configures theHttpClient5Cache
that is used by the#getHttpClient(String)
and#getHttpClient(Destination)
methods.By default, this uses an implementation, which caches the
HttpClient
for 5 minutes.CAUTION: This factory is accessed concurrently. Therefore, you have to make sure that you do not introduce any concurrency issues when changing the factory. Furthermore, be aware that setting a custom factory will affect all consumers of the
ApacheHttpClient5Accessor
within the application. -
getHttpClientFactory
Returns theApacheHttpClient5Factory
that is used when creating instances ofHttpClient
within theApacheHttpClient5Accessor
.
-