public class CacheFirstCacheHandler extends AbstractRestCacheHandler
IOperationCacheHandler
that can be used when offline or
for static resources as it first checks if the requested resource is
available in the cache. The operation is only executed if the requested
resource is not found in the cache.Constructor and Description |
---|
CacheFirstCacheHandler() |
CacheFirstCacheHandler(java.lang.String mimeType,
java.lang.String encoding) |
Modifier and Type | Method and Description |
---|---|
void |
afterOperationExecution(IOperation operation)
Is invoked after the operation itself is started with
IOperation#internalExecute() . |
void |
beforeOperationExecution(IOperation operation)
Is invoked before the operation itself is started with
IOperation#internalExecute() . |
void |
onOperationFinished(IOperation operation)
Notifies this listener that the watched
IOperation finished. |
boolean |
skipOperationExecution(IOperation operation) |
getCacheManager
setCacheManager
onOperationSuccessful
onOperationFailed
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onOperationFailed
public CacheFirstCacheHandler()
public CacheFirstCacheHandler(java.lang.String mimeType, java.lang.String encoding)
public void beforeOperationExecution(IOperation operation)
IOperationCacheHandler
IOperation#internalExecute()
. Can be used to read some data from
the cache and set it into the operation.beforeOperationExecution
in interface IOperationCacheHandler
beforeOperationExecution
in class NoCacheHandler
public void afterOperationExecution(IOperation operation)
IOperationCacheHandler
IOperation#internalExecute()
. Can be used to read data from the
operation and write it into the cache.afterOperationExecution
in interface IOperationCacheHandler
afterOperationExecution
in class AbstractRestCacheHandler
public boolean skipOperationExecution(IOperation operation)
skipOperationExecution
in interface IOperationCacheHandler
skipOperationExecution
in class NoCacheHandler
IOperation
should be
skipped, e.g. if the result is offline and the operation will
fail anyway (with a costly timeout).public void onOperationFinished(IOperation operation)
IOperationDelegate
IOperation
finished. IOperation.getResultCode()
to validate the success of the
operation. E.g. for a remote operation:
switch (operation.getResultCode()) { caseHttpConnection.HTTP_OK
: break; caseHttpConnection.HTTP_FORBIDDEN
: break; }
onOperationFinished
in interface IOperationDelegate
onOperationFinished
in class AbstractRestCacheHandler
operation
- The watched IOperation
.