public final class HttpClientAccessor extends Object
HttpClients.| Constructor and Description |
|---|
HttpClientAccessor() |
| Modifier and Type | Method and Description |
|---|---|
static org.apache.http.client.HttpClient |
getHttpClient() |
static org.apache.http.client.HttpClient |
getHttpClient(Destination destination) |
static org.apache.http.client.HttpClient |
getHttpClient(String destinationName) |
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 HttpClientFactory |
getHttpClientProvider()
Deprecated.
Use
getHttpClientFactory() instead. |
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 void |
setHttpClientProvider(HttpClientFactory httpClientFactory)
Deprecated.
Use
setHttpClientFactory(HttpClientFactory) instead. |
@Nonnull public static HttpClientFactory getHttpClientFactory()
HttpClientFactory that is used when creating instances of HttpClient within the
HttpClientAccessor.HttpClientFactory.@Deprecated @Nonnull public static HttpClientFactory getHttpClientProvider()
getHttpClientFactory() instead.HttpClientFactory.public static void setHttpClientFactory(@Nonnull 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.@Deprecated public static void setHttpClientProvider(@Nonnull HttpClientFactory httpClientFactory)
setHttpClientFactory(HttpClientFactory) instead.httpClientFactory - The global HttpClientFactory instance to be used.@Nonnull public static org.apache.http.client.HttpClient getHttpClient() throws HttpClientInstantiationException
HttpClient independent of any destination.HttpClientInstantiationException - If there is an issue creating the HttpClient.@Nonnull public static org.apache.http.client.HttpClient getHttpClient(@Nonnull String destinationName) throws DestinationNotFoundException, DestinationAccessException, HttpClientInstantiationException
destinationName - The name of the destination to get the HttpClient for.HttpClient for the Destination with the given name. The instance may be cached.DestinationNotFoundException - If no Destination can be found for the given name.DestinationAccessException - If there is an issue accessing the Destination.HttpClientInstantiationException - If there is an issue creating the HttpClient.@Nonnull public static org.apache.http.client.HttpClient getHttpClient(@Nonnull Destination destination) throws DestinationAccessException, HttpClientInstantiationException
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 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 © 2018 SAP SE. All rights reserved.