public final class HttpClientAccessor extends Object
HttpClients.| Modifier and Type | Method and Description |
|---|---|
static org.apache.http.client.HttpClient |
getHttpClient()
Returns an
HttpClient independent of any destination. |
static org.apache.http.client.HttpClient |
getHttpClient(HttpDestinationProperties destination)
Returns an
HttpClient for the given Destination. |
static HttpClientCache |
getHttpClientCache()
Configures the
HttpClientCache that is used by the #getHttpClient(String) and
#getHttpClient(Destination) methods. |
static HttpClientFactory |
getHttpClientFactory()
Returns the
HttpClientFactory that is used when creating instances of HttpClient within the
HttpClientAccessor. |
static void |
setHttpClientCache(HttpClientCache httpClientCache)
Configures the
HttpClientCache that is used by the #getHttpClient(String) and
#getHttpClient(Destination) methods. |
static void |
setHttpClientFactory(HttpClientFactory httpClientFactory)
Sets the
HttpClientFactory that is used when creating instances of HttpClient within the
HttpClientAccessor. |
static io.vavr.control.Try<org.apache.http.client.HttpClient> |
tryGetHttpClient()
Returns an
HttpClient independent of any destination. |
static io.vavr.control.Try<org.apache.http.client.HttpClient> |
tryGetHttpClient(HttpDestinationProperties destination)
|
@Nonnull public static HttpClientFactory getHttpClientFactory()
HttpClientFactory that is used when creating instances of HttpClient within the
HttpClientAccessor.HttpClientFactory.public static void setHttpClientFactory(@Nullable HttpClientFactory httpClientFactory)
HttpClientFactory that is used when creating instances of HttpClient within the
HttpClientAccessor.
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.
httpClientFactory - The global HttpClientFactory instance to be used. Use null to reset the factory.@Nonnull public static org.apache.http.client.HttpClient getHttpClient() throws HttpClientInstantiationException
HttpClient independent of any destination.HttpClient independent of any destination.HttpClientInstantiationException - If there is an issue creating the HttpClient.@Nonnull public static io.vavr.control.Try<org.apache.http.client.HttpClient> tryGetHttpClient()
HttpClient independent of any destination.HttpClient independent of any destination.@Nonnull public static org.apache.http.client.HttpClient getHttpClient(@Nonnull HttpDestinationProperties destination) throws DestinationAccessException, HttpClientInstantiationException
HttpClient for the given Destination. The instance may be cached.destination - The destination to get the HttpClient for.HttpClient for the given Destination. The instance may be cached.DestinationAccessException - If there is an issue accessing the Destination.HttpClientInstantiationException - If there is an issue creating the HttpClient.@Nonnull public static io.vavr.control.Try<org.apache.http.client.HttpClient> tryGetHttpClient(@Nonnull HttpDestinationProperties destination)
destination - The destination to get the HttpClient for.Try of an HttpClient for the given Destination. The instance may be cached.@Nonnull public static HttpClientCache getHttpClientCache()
HttpClientCache that is used by the #getHttpClient(String) and
#getHttpClient(Destination) methods.
By default this uses the RequestScopedHttpClientCache implementation, which caches an HttpClient
for the life time of the current request.
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.
public static void setHttpClientCache(@Nonnull HttpClientCache httpClientCache)
HttpClientCache that is used by the #getHttpClient(String) and
#getHttpClient(Destination) methods.
By default this uses the RequestScopedHttpClientCache implementation, which caches an HttpClient
for the life time of the current request.
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.
Copyright © 2021 SAP SE. All rights reserved.