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.Runnable
Class used to represent an asynchronous revalidation event, such as with "stale-while-revalidate"
-
-
Field Summary
Fields Modifier and Type Field Description private HttpCacheEntry
cacheEntry
private CachingExec
cachingExec
private int
consecutiveFailedAttempts
private HttpClientContext
context
private HttpExecutionAware
execAware
private java.lang.String
identifier
private org.apache.commons.logging.Log
log
private AsynchronousValidator
parent
private HttpRequestWrapper
request
private HttpRoute
route
-
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 byAsynchronousValidator
to schedule a revalidation.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getConsecutiveFailedAttempts()
The number of consecutively failed revalidation attempts.java.lang.String
getIdentifier()
private boolean
isNotServerError(int statusCode)
Return whether the status code indicates a server error or not.private boolean
isNotStale(org.apache.http.HttpResponse httpResponse)
Try to detect if the returned response is generated from a stale cache entry.private boolean
revalidateCacheEntry()
Revalidate the cache entry and return if the operation was successful.void
run()
-
-
-
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 byAsynchronousValidator
to schedule a revalidation.- Parameters:
request
-context
-cacheEntry
-identifier
-consecutiveFailedAttempts
-
-
-
Method Detail
-
run
public void run()
- Specified by:
run
in 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:
true
if 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.
-
-