Class AsynchronousValidationRequest
- java.lang.Object
-
- org.apache.http.impl.client.cache.AsynchronousValidationRequest
-
- All Implemented Interfaces:
java.lang.Runnable
public class AsynchronousValidationRequest extends java.lang.Object implements java.lang.RunnableClass used to represent an asynchronous revalidation event, such as with "stale-while-revalidate"
-
-
Field Summary
Fields Modifier and Type Field Description private HttpCacheEntrycacheEntryprivate CachingExeccachingExecprivate intconsecutiveFailedAttemptsprivate HttpClientContextcontextprivate HttpExecutionAwareexecAwareprivate java.lang.Stringidentifierprivate org.apache.commons.logging.Loglogprivate AsynchronousValidatorparentprivate HttpRequestWrapperrequestprivate HttpRouteroute
-
Constructor Summary
Constructors Constructor Description AsynchronousValidationRequest(AsynchronousValidator parent, CachingExec cachingExec, HttpRoute route, HttpRequestWrapper request, HttpClientContext context, HttpExecutionAware execAware, HttpCacheEntry cacheEntry, java.lang.String identifier, int consecutiveFailedAttempts)Used internally byAsynchronousValidatorto schedule a revalidation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetConsecutiveFailedAttempts()The number of consecutively failed revalidation attempts.java.lang.StringgetIdentifier()private booleanisNotServerError(int statusCode)Return whether the status code indicates a server error or not.private booleanisNotStale(org.apache.http.HttpResponse httpResponse)Try to detect if the returned response is generated from a stale cache entry.private booleanrevalidateCacheEntry()Revalidate the cache entry and return if the operation was successful.voidrun()
-
-
-
Field Detail
-
parent
private final AsynchronousValidator parent
-
cachingExec
private final CachingExec cachingExec
-
route
private final HttpRoute route
-
request
private final HttpRequestWrapper request
-
context
private final HttpClientContext context
-
execAware
private final HttpExecutionAware execAware
-
cacheEntry
private final HttpCacheEntry cacheEntry
-
identifier
private final java.lang.String identifier
-
consecutiveFailedAttempts
private final int consecutiveFailedAttempts
-
log
private final org.apache.commons.logging.Log log
-
-
Constructor Detail
-
AsynchronousValidationRequest
AsynchronousValidationRequest(AsynchronousValidator parent, CachingExec cachingExec, HttpRoute route, HttpRequestWrapper request, HttpClientContext context, HttpExecutionAware execAware, HttpCacheEntry cacheEntry, java.lang.String identifier, int consecutiveFailedAttempts)
Used internally byAsynchronousValidatorto schedule a revalidation.- Parameters:
request-context-cacheEntry-identifier-consecutiveFailedAttempts-
-
-
Method Detail
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
revalidateCacheEntry
private boolean revalidateCacheEntry()
Revalidate the cache entry and return if the operation was successful. Success means a connection to the server was established and replay did not indicate a server error.- Returns:
trueif the cache entry was successfully validated; otherwisefalse
-
isNotServerError
private boolean isNotServerError(int statusCode)
Return whether the status code indicates a server error or not.- Parameters:
statusCode- the status code to be checked- Returns:
- if the status code indicates a server error or not
-
isNotStale
private boolean isNotStale(org.apache.http.HttpResponse httpResponse)
Try to detect if the returned response is generated from a stale cache entry.- Parameters:
httpResponse- the response to be checked- Returns:
- whether the response is stale or not
-
getIdentifier
public java.lang.String getIdentifier()
-
getConsecutiveFailedAttempts
public int getConsecutiveFailedAttempts()
The number of consecutively failed revalidation attempts.- Returns:
- the number of consecutively failed revalidation attempts.
-
-