Class AsyncCachingExec
- java.lang.Object
-
- org.apache.hc.client5.http.impl.cache.CachingExecBase
-
- org.apache.hc.client5.http.impl.cache.AsyncCachingExec
-
- All Implemented Interfaces:
AsyncExecChainHandler
@Contract(threading=SAFE) class AsyncCachingExec extends CachingExecBase implements AsyncExecChainHandler
Request executor in the request execution chain that is responsible for transparent client-side caching.The current implementation is conditionally compliant with HTTP/1.1 (meaning all the MUST and MUST NOTs are obeyed), although quite a lot, though not all, of the SHOULDs and SHOULD NOTs are obeyed too.
- Since:
- 5.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
AsyncCachingExec.AsyncExecCallbackWrapper
(package private) class
AsyncCachingExec.BackendResponseHandler
(package private) class
AsyncCachingExec.CachingAsyncDataConsumer
-
Field Summary
Fields Modifier and Type Field Description private DefaultAsyncCacheRevalidator
cacheRevalidator
private ConditionalRequestBuilder<org.apache.hc.core5.http.HttpRequest>
conditionalRequestBuilder
private static org.slf4j.Logger
LOG
private HttpAsyncCache
responseCache
-
Fields inherited from class org.apache.hc.client5.http.impl.cache.CachingExecBase
cacheableRequestPolicy, cacheConfig, cacheHits, cacheMisses, cacheUpdates, requestCompliance, responseCachingPolicy, responseCompliance, responseGenerator, suitabilityChecker, SUPPORTS_RANGE_AND_CONTENT_RANGE_HEADERS, validityPolicy, viaHeaders
-
-
Constructor Summary
Constructors Constructor Description AsyncCachingExec(ResourceFactory resourceFactory, HttpAsyncCacheStorage storage, java.util.concurrent.ScheduledExecutorService executorService, SchedulingStrategy schedulingStrategy, CacheConfig config)
AsyncCachingExec(HttpAsyncCache cache, java.util.concurrent.ScheduledExecutorService executorService, SchedulingStrategy schedulingStrategy, CacheConfig config)
AsyncCachingExec(HttpAsyncCache responseCache, CacheValidityPolicy validityPolicy, ResponseCachingPolicy responseCachingPolicy, CachedHttpResponseGenerator responseGenerator, CacheableRequestPolicy cacheableRequestPolicy, CachedResponseSuitabilityChecker suitabilityChecker, ResponseProtocolCompliance responseCompliance, RequestProtocolCompliance requestCompliance, DefaultAsyncCacheRevalidator cacheRevalidator, ConditionalRequestBuilder<org.apache.hc.core5.http.HttpRequest> conditionalRequestBuilder, CacheConfig config)
AsyncCachingExec(HttpAsyncCache cache, DefaultAsyncCacheRevalidator cacheRevalidator, CacheConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
callBackend(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback)
(package private) void
chainProceed(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback)
void
execute(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback)
Executes the actual HTTP request.private void
handleCacheHit(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback, HttpCacheEntry entry)
private void
handleCacheMiss(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback)
(package private) void
negotiateResponseFromVariants(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback, java.util.Map<java.lang.String,Variant> variants)
(package private) void
revalidateCacheEntry(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback, HttpCacheEntry cacheEntry)
private void
triggerResponse(SimpleHttpResponse cacheResponse, AsyncExecChain.Scope scope, AsyncExecCallback asyncExecCallback)
-
Methods inherited from class org.apache.hc.client5.http.impl.cache.CachingExecBase
clientRequestsOurOptions, explicitFreshnessRequest, generateCachedResponse, generateGatewayTimeout, generateViaHeader, getCacheHits, getCacheMisses, getCacheUpdates, getCurrentDate, getFatallyNonCompliantResponse, handleRevalidationFailure, mayCallBackend, recordCacheFailure, recordCacheHit, recordCacheMiss, recordCacheUpdate, revalidationResponseIsTooOld, setResponseStatus, shouldSendNotModifiedResponse, staleIfErrorAppliesTo, staleResponseNotAllowed, storeRequestIfModifiedSinceFor304Response, supportsRangeAndContentRangeHeaders, unvalidatedCacheHit
-
-
-
-
Field Detail
-
LOG
private static final org.slf4j.Logger LOG
-
responseCache
private final HttpAsyncCache responseCache
-
cacheRevalidator
private final DefaultAsyncCacheRevalidator cacheRevalidator
-
conditionalRequestBuilder
private final ConditionalRequestBuilder<org.apache.hc.core5.http.HttpRequest> conditionalRequestBuilder
-
-
Constructor Detail
-
AsyncCachingExec
AsyncCachingExec(HttpAsyncCache cache, DefaultAsyncCacheRevalidator cacheRevalidator, CacheConfig config)
-
AsyncCachingExec
AsyncCachingExec(HttpAsyncCache responseCache, CacheValidityPolicy validityPolicy, ResponseCachingPolicy responseCachingPolicy, CachedHttpResponseGenerator responseGenerator, CacheableRequestPolicy cacheableRequestPolicy, CachedResponseSuitabilityChecker suitabilityChecker, ResponseProtocolCompliance responseCompliance, RequestProtocolCompliance requestCompliance, DefaultAsyncCacheRevalidator cacheRevalidator, ConditionalRequestBuilder<org.apache.hc.core5.http.HttpRequest> conditionalRequestBuilder, CacheConfig config)
-
AsyncCachingExec
AsyncCachingExec(HttpAsyncCache cache, java.util.concurrent.ScheduledExecutorService executorService, SchedulingStrategy schedulingStrategy, CacheConfig config)
-
AsyncCachingExec
AsyncCachingExec(ResourceFactory resourceFactory, HttpAsyncCacheStorage storage, java.util.concurrent.ScheduledExecutorService executorService, SchedulingStrategy schedulingStrategy, CacheConfig config)
-
-
Method Detail
-
triggerResponse
private void triggerResponse(SimpleHttpResponse cacheResponse, AsyncExecChain.Scope scope, AsyncExecCallback asyncExecCallback)
-
execute
public void execute(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback) throws org.apache.hc.core5.http.HttpException, java.io.IOException
Description copied from interface:AsyncExecChainHandler
Executes the actual HTTP request. The handler can choose to return a response message immediately inside the call or asynchronously at some later point or delegate request execution to the next element in the execution chain.- Specified by:
execute
in interfaceAsyncExecChainHandler
- Parameters:
request
- the actual request.entityProducer
- the request entity producer ornull
if the request does not enclose an entity.scope
- the execution scope .chain
- the next element in the request execution chain.asyncExecCallback
- the execution callback.- Throws:
org.apache.hc.core5.http.HttpException
java.io.IOException
-
chainProceed
void chainProceed(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback)
-
callBackend
void callBackend(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback)
-
handleCacheHit
private void handleCacheHit(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback, HttpCacheEntry entry)
-
revalidateCacheEntry
void revalidateCacheEntry(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback, HttpCacheEntry cacheEntry)
-
handleCacheMiss
private void handleCacheMiss(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback)
-
negotiateResponseFromVariants
void negotiateResponseFromVariants(org.apache.hc.core5.http.HttpHost target, org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback, java.util.Map<java.lang.String,Variant> variants)
-
-