public class TimeScopedHttpClientCache extends HttpClientCache
HttpClientCache
, caching the HttpClient
s for the amount of time given in the
constructor.Constructor and Description |
---|
TimeScopedHttpClientCache(long duration,
TimeUnit unit)
Caches the
HttpClient for the given duration. |
Modifier and Type | Method and Description |
---|---|
protected Optional<com.google.common.cache.Cache<CacheKey,org.apache.http.client.HttpClient>> |
getCache()
Getter for the cache to be used.
|
protected com.google.common.cache.CacheBuilder<Object,Object> |
getCacheBuilder(long duration,
TimeUnit unit) |
protected CacheKey |
getCacheKey()
Method called in the
#getClient(HttpClientFactory) method to create a CacheKey for no specific
Destination . |
protected CacheKey |
getCacheKey(Destination destination)
Method called in the
#getClient(Destination, HttpClientFactory) method to create a CacheKey for
the given Destination . |
getHttpClient, getHttpClient
protected com.google.common.cache.CacheBuilder<Object,Object> getCacheBuilder(long duration, @Nonnull TimeUnit unit)
@Nonnull protected Optional<com.google.common.cache.Cache<CacheKey,org.apache.http.client.HttpClient>> getCache()
If the optional is empty a new HttpClient
will be created and not cached.
getCache
in class HttpClientCache
Optional
that may contain the cache to be used by the
HttpClientCache.getHttpClient(Destination, HttpClientFactory)
method.@Nonnull protected CacheKey getCacheKey(@Nonnull Destination destination) throws HttpClientInstantiationException
#getClient(Destination, HttpClientFactory)
method to create a CacheKey
for
the given Destination
.getCacheKey
in class HttpClientCache
destination
- The destination to create a CacheKey
for.CacheKey
for destination.
HttpClientInstantiationException
- If there is an issue while accessing the cache key.@Nonnull protected CacheKey getCacheKey() throws HttpClientInstantiationException
#getClient(HttpClientFactory)
method to create a CacheKey
for no specific
Destination
.getCacheKey
in class HttpClientCache
CacheKey
for a generic http client.HttpClientInstantiationException
- If there is an issue while accessing the cache key.Copyright © 2018 SAP SE. All rights reserved.