public final class HttpClientAccessor extends Object
HttpClient
s.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 |
getHttpClientProvider()
Configures 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 |
setHttpClientProvider(HttpClientFactory httpClientProvider)
Configures the
HttpClientFactory that is used when creating instances of HttpClient within the
HttpClientAccessor . |
@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 HttpClientFactory getHttpClientProvider()
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.
public static void setHttpClientProvider(@Nonnull HttpClientFactory httpClientProvider)
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.
@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.