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 classAsyncCachingExec.AsyncExecCallbackWrapper(package private) classAsyncCachingExec.BackendResponseHandler(package private) classAsyncCachingExec.CachingAsyncDataConsumer
-
Field Summary
Fields Modifier and Type Field Description private DefaultAsyncCacheRevalidatorcacheRevalidatorprivate ConditionalRequestBuilder<org.apache.hc.core5.http.HttpRequest>conditionalRequestBuilderprivate static org.slf4j.LoggerLOGprivate HttpAsyncCacheresponseCache-
Fields inherited from class org.apache.hc.client5.http.impl.cache.CachingExecBase
cacheableRequestPolicy, cacheConfig, cacheHits, cacheMisses, cacheUpdates, responseCachingPolicy, responseGenerator, suitabilityChecker, validityPolicy
-
-
Constructor Summary
Constructors Constructor Description AsyncCachingExec(HttpAsyncCache cache, java.util.concurrent.ScheduledExecutorService executorService, SchedulingStrategy schedulingStrategy, CacheConfig config)AsyncCachingExec(HttpAsyncCache cache, DefaultAsyncCacheRevalidator cacheRevalidator, CacheConfig config)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) voidcallBackend(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) voidchainProceed(org.apache.hc.core5.http.HttpRequest request, org.apache.hc.core5.http.nio.AsyncEntityProducer entityProducer, AsyncExecChain.Scope scope, AsyncExecChain chain, AsyncExecCallback asyncExecCallback)voiddoExecute(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)voidexecute(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 voidhandleCacheHit(RequestCacheControl requestCacheControl, ResponseCacheControl responseCacheControl, CacheHit hit, 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)private voidhandleCacheMiss(RequestCacheControl requestCacheControl, CacheHit partialMatch, 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) voidnegotiateResponseFromVariants(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.Collection<CacheHit> variants)(package private) voidrevalidateCacheEntry(ResponseCacheControl responseCacheControl, CacheHit hit, 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) voidrevalidateCacheEntryWithFallback(RequestCacheControl requestCacheControl, ResponseCacheControl responseCacheControl, CacheHit hit, 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) voidrevalidateCacheEntryWithoutFallback(ResponseCacheControl responseCacheControl, CacheHit hit, 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)private voidtriggerResponse(SimpleHttpResponse cacheResponse, AsyncExecChain.Scope scope, AsyncExecCallback asyncExecCallback)-
Methods inherited from class org.apache.hc.client5.http.impl.cache.CachingExecBase
clientRequestsOurOptions, generateCachedResponse, generateGatewayTimeout, getCacheHits, getCacheMisses, getCacheUpdates, getCurrentDate, isResponseTooBig, shouldSendNotModifiedResponse, staleIfErrorAppliesTo, storeRequestIfModifiedSinceFor304Response
-
-
-
-
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 cache, 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.IOExceptionDescription copied from interface:AsyncExecChainHandlerExecutes 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:
executein interfaceAsyncExecChainHandler- Parameters:
request- the actual request.entityProducer- the request entity producer ornullif 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- If a protocol error occurs.java.io.IOException- If an I/O error occurs.
-
doExecute
public void doExecute(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) throws org.apache.hc.core5.http.HttpException, java.io.IOException- Throws:
org.apache.hc.core5.http.HttpExceptionjava.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(RequestCacheControl requestCacheControl, ResponseCacheControl responseCacheControl, CacheHit hit, 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)
-
revalidateCacheEntry
void revalidateCacheEntry(ResponseCacheControl responseCacheControl, CacheHit hit, 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)
-
revalidateCacheEntryWithoutFallback
void revalidateCacheEntryWithoutFallback(ResponseCacheControl responseCacheControl, CacheHit hit, 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)
-
revalidateCacheEntryWithFallback
void revalidateCacheEntryWithFallback(RequestCacheControl requestCacheControl, ResponseCacheControl responseCacheControl, CacheHit hit, 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)
-
handleCacheMiss
private void handleCacheMiss(RequestCacheControl requestCacheControl, CacheHit partialMatch, 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.Collection<CacheHit> variants)
-
-