public abstract class AbstractOfflineAwareCacheHandler extends AbstractRestCacheHandler
IOperationCacheHandler
that
changes behavior depending on the connection status (online/offline).
The application needs to implements the isOnline()
method to
determine when the backend is available and the operation should be executed.
Constructor and Description |
---|
AbstractOfflineAwareCacheHandler() |
AbstractOfflineAwareCacheHandler(java.lang.String mimeType,
java.lang.String encoding) |
Modifier and Type | Method and Description |
---|---|
void |
beforeOperationExecution(IOperation operation)
Is invoked before the operation itself is started with
IOperation#internalExecute() . |
abstract boolean |
isOnline() |
void |
onOperationFinished(IOperation operation)
Notifies this listener that the watched
IOperation finished. |
boolean |
skipOperationExecution(IOperation operation) |
afterOperationExecution, getCacheManager
setCacheManager
onOperationSuccessful
onOperationFailed
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onOperationFailed
public AbstractOfflineAwareCacheHandler()
public AbstractOfflineAwareCacheHandler(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 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
.public abstract boolean isOnline()
true
if the app is currently online and the required
backend is available, the operation will be executed;
false
otherwise, the operation will be skipped