Class AbstractHttpClientCache
java.lang.Object
com.sap.cloud.sdk.cloudplatform.connectivity.AbstractHttpClientCache
- All Implemented Interfaces:
HttpClientCache
- Direct Known Subclasses:
DefaultHttpClientCache
Provides caching functionality to the
HttpClientAccessor.-
Field Summary
Fields inherited from interface com.sap.cloud.sdk.cloudplatform.connectivity.HttpClientCache
DISABLED -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract io.vavr.control.Try<com.github.benmanes.caffeine.cache.Cache<CacheKey,org.apache.http.client.HttpClient>> getCache()Getter for the cache to be used.protected abstract io.vavr.control.Try<CacheKey>Method called in the#getClient(HttpClientFactory)method to create aCacheKeyfor no specificDestination.protected abstract io.vavr.control.Try<CacheKey>getCacheKey(HttpDestinationProperties destination) Method called in the#getClient(Destination, HttpClientFactory)method to create aCacheKeyfor the givenDestination.io.vavr.control.Try<org.apache.http.client.HttpClient>tryGetHttpClient(HttpClientFactory httpClientFactory) Gets the non-destination-specificHttpClientfrom this cache.io.vavr.control.Try<org.apache.http.client.HttpClient>tryGetHttpClient(HttpDestinationProperties destination, HttpClientFactory httpClientFactory) Gets theHttpClientfor the givenDestinationfrom this cache.
-
Constructor Details
-
AbstractHttpClientCache
public AbstractHttpClientCache()
-
-
Method Details
-
tryGetHttpClient
@Nonnull public io.vavr.control.Try<org.apache.http.client.HttpClient> tryGetHttpClient(@Nonnull HttpDestinationProperties destination, @Nonnull HttpClientFactory httpClientFactory) Gets theHttpClientfor the givenDestinationfrom this cache.If there is no
HttpClientfordestinationit is created by using theHttpClientFactory.- Specified by:
tryGetHttpClientin interfaceHttpClientCache- Parameters:
destination- TheDestinationto get theHttpClientfor.httpClientFactory- TheHttpClientFactoryused to create a newHttpClientif no cached one can be found.- Returns:
- A
Tryof the cachedHttpClientfor the givenDestination.
-
tryGetHttpClient
@Nonnull public io.vavr.control.Try<org.apache.http.client.HttpClient> tryGetHttpClient(@Nonnull HttpClientFactory httpClientFactory) Gets the non-destination-specificHttpClientfrom this cache.If there is no generic
HttpClientit is created by using theHttpClientFactory.- Specified by:
tryGetHttpClientin interfaceHttpClientCache- Parameters:
httpClientFactory- TheHttpClientFactoryused to create a newHttpClientif no cached one can be found.- Returns:
- A
Tryof the cachedHttpClient.
-
getCache
@Nonnull protected abstract io.vavr.control.Try<com.github.benmanes.caffeine.cache.Cache<CacheKey,org.apache.http.client.HttpClient>> getCache()Getter for the cache to be used.If the optional is empty a new
HttpClientwill be created and not cached.- Returns:
- A
Tryof the cache to be used by thetryGetHttpClient(HttpDestinationProperties, HttpClientFactory)method. - Throws:
HttpClientInstantiationException- If there is an issue while accessing the cache.
-
getCacheKey
@Nonnull protected abstract io.vavr.control.Try<CacheKey> getCacheKey(@Nonnull HttpDestinationProperties destination) Method called in the#getClient(Destination, HttpClientFactory)method to create aCacheKeyfor the givenDestination.- Parameters:
destination- The destination to create aCacheKeyfor.- Returns:
- A
Tryof theCacheKeyfordestination. - Throws:
HttpClientInstantiationException- If there is an issue while accessing the cache key.
-
getCacheKey
Method called in the#getClient(HttpClientFactory)method to create aCacheKeyfor no specificDestination.- Returns:
- A
Tryof theCacheKeyfor a genericHttpClient. - Throws:
HttpClientInstantiationException- If there is an issue while accessing the cache key.
-