Class HttpClientAccessor
HttpClient
s.-
Method Summary
Modifier and TypeMethodDescriptionstatic org.apache.http.client.HttpClient
Returns anHttpClient
independent of any destination.static org.apache.http.client.HttpClient
getHttpClient
(Destination destination) Returns anHttpClient
for the givenDestination
.static org.apache.http.client.HttpClient
getHttpClient
(HttpDestinationProperties destination) Returns anHttpClient
for the givenDestination
.static HttpClientCache
Configures theHttpClientCache
that is used by the#getHttpClient(String)
and#getHttpClient(Destination)
methods.static HttpClientFactory
Returns theHttpClientFactory
that is used when creating instances ofHttpClient
within theHttpClientAccessor
.static void
setHttpClientCache
(HttpClientCache httpClientCache) Sets theHttpClientCache
that is used when resolving cached instances ofHttpClient
within theHttpClientAccessor
.static void
setHttpClientFactory
(HttpClientFactory httpClientFactory) Sets theHttpClientFactory
that is used when creating instances ofHttpClient
within theHttpClientAccessor
.static io.vavr.control.Try<org.apache.http.client.HttpClient>
Returns anHttpClient
independent of any destination.static io.vavr.control.Try<org.apache.http.client.HttpClient>
tryGetHttpClient
(Destination destination)
-
Method Details
-
getHttpClientFactory
Returns theHttpClientFactory
that is used when creating instances ofHttpClient
within theHttpClientAccessor
.- Returns:
- The
HttpClientFactory
.
-
setHttpClientFactory
Sets theHttpClientFactory
that is used when creating instances ofHttpClient
within theHttpClientAccessor
.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
HttpClientAccessor
within the application.- Parameters:
httpClientFactory
- The globalHttpClientFactory
instance to be used. Usenull
to reset the factory.
-
setHttpClientCache
Sets theHttpClientCache
that is used when resolving cached instances ofHttpClient
within theHttpClientAccessor
.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
HttpClientAccessor
within the application.- Parameters:
httpClientCache
- The globalHttpClientCache
instance to be used. Usenull
to reset the cache.
-
getHttpClient
@Nonnull public static org.apache.http.client.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.http.client.HttpClient> tryGetHttpClient()Returns anHttpClient
independent of any destination.- Returns:
- An
HttpClient
independent of any destination.
-
getHttpClient
@Nonnull public static org.apache.http.client.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.http.client.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.http.client.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 theHttpClientCache
that is used by the#getHttpClient(String)
and#getHttpClient(Destination)
methods.By default, this uses the
DefaultHttpClientCache
implementation, which caches theHttpClient
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
HttpClientAccessor
within the application.
-