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
-
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 aCacheKey
for no specificDestination
.protected abstract io.vavr.control.Try<CacheKey>
getCacheKey
(HttpDestinationProperties destination) Method called in the#getClient(Destination, HttpClientFactory)
method to create aCacheKey
for the givenDestination
.io.vavr.control.Try<org.apache.http.client.HttpClient>
tryGetHttpClient
(HttpClientFactory httpClientFactory) Gets the non-destination-specificHttpClient
from this cache.io.vavr.control.Try<org.apache.http.client.HttpClient>
tryGetHttpClient
(HttpDestinationProperties destination, HttpClientFactory httpClientFactory) Gets theHttpClient
for the givenDestination
from 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 theHttpClient
for the givenDestination
from this cache.If there is no
HttpClient
fordestination
it is created by using theHttpClientFactory
.- Specified by:
tryGetHttpClient
in interfaceHttpClientCache
- Parameters:
destination
- TheDestination
to get theHttpClient
for.httpClientFactory
- TheHttpClientFactory
used to create a newHttpClient
if no cached one can be found.- Returns:
- A
Try
of the cachedHttpClient
for the givenDestination
.
-
tryGetHttpClient
@Nonnull public io.vavr.control.Try<org.apache.http.client.HttpClient> tryGetHttpClient(@Nonnull HttpClientFactory httpClientFactory) Gets the non-destination-specificHttpClient
from this cache.If there is no generic
HttpClient
it is created by using theHttpClientFactory
.- Specified by:
tryGetHttpClient
in interfaceHttpClientCache
- Parameters:
httpClientFactory
- TheHttpClientFactory
used to create a newHttpClient
if no cached one can be found.- Returns:
- A
Try
of 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
HttpClient
will be created and not cached.- Returns:
- A
Try
of 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 aCacheKey
for the givenDestination
.- Parameters:
destination
- The destination to create aCacheKey
for.- Returns:
- A
Try
of theCacheKey
fordestination.
- Throws:
HttpClientInstantiationException
- If there is an issue while accessing the cache key.
-
getCacheKey
Method called in the#getClient(HttpClientFactory)
method to create aCacheKey
for no specificDestination
.- Returns:
- A
Try
of theCacheKey
for a genericHttpClient
. - Throws:
HttpClientInstantiationException
- If there is an issue while accessing the cache key.
-