public class ServerFirstCacheHandler extends AbstractRestCacheHandler
IOperationCacheHandler
that
executes the operation and stores a successful result in the cache. If the
operation failed (e.g. if the backend is not available), the handler tries to
load the requested resource in the cache.Constructor and Description |
---|
ServerFirstCacheHandler() |
ServerFirstCacheHandler(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 |
onOperationFailed(IOperation operation)
Notifies this listener that the watched
IOperation failed. |
void |
onOperationSuccessful(IOperation operation)
Is called when the operation executed successfully (i.e.
|
boolean |
skipOperationExecution(IOperation operation) |
getCacheManager, onOperationFinished
setCacheManager
public ServerFirstCacheHandler()
public ServerFirstCacheHandler(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 onOperationFailed(IOperation operation)
IOperationDelegate
IOperation
failed. This only
indicates an exception during the execution and is independent from the
operation's result code.onOperationFailed
in interface IOperationDelegate
onOperationFailed
in class AbstractOperationDelegate
operation
- The watched IOperation
.public void onOperationSuccessful(IOperation operation)
AbstractOperationDelegate
onOperationSuccessful
in class NoCacheHandler
operation
- the successful IOperation
(incl. the result string)