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 ClassesModifier and TypeClassDescription(package private) static class(package private) class(package private) class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final DefaultAsyncCacheRevalidatorprivate final ConditionalRequestBuilder<org.apache.hc.core5.http.HttpRequest> private static final org.slf4j.Loggerprivate final HttpAsyncCacheFields inherited from class CachingExecBase
cacheableRequestPolicy, cacheConfig, cacheHits, cacheMisses, cacheUpdates, responseCachingPolicy, responseGenerator, suitabilityChecker, validityPolicy -
Constructor Summary
ConstructorsConstructorDescriptionAsyncCachingExec(HttpAsyncCache cache, ScheduledExecutorService executorService, SchedulingStrategy schedulingStrategy, CacheConfig config) AsyncCachingExec(HttpAsyncCache cache, DefaultAsyncCacheRevalidator cacheRevalidator, CacheConfig config) -
Method Summary
Modifier and TypeMethodDescription(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, 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)
-
Field Details
-
LOG
private static final org.slf4j.Logger LOG -
responseCache
-
cacheRevalidator
-
conditionalRequestBuilder
private final ConditionalRequestBuilder<org.apache.hc.core5.http.HttpRequest> conditionalRequestBuilder
-
-
Constructor Details
-
AsyncCachingExec
AsyncCachingExec(HttpAsyncCache cache, DefaultAsyncCacheRevalidator cacheRevalidator, CacheConfig config) -
AsyncCachingExec
AsyncCachingExec(HttpAsyncCache cache, ScheduledExecutorService executorService, SchedulingStrategy schedulingStrategy, CacheConfig config)
-
-
Method Details
-
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, IOException Description 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.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, IOException - Throws:
org.apache.hc.core5.http.HttpExceptionIOException
-
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, Collection<CacheHit> variants)
-