public class ConditionalOperationQueue extends BasicOperationQueue implements IOperationDelegate
IOperationQueue
which offers the
ability to execute several IOperation
s. Using
addConditionalOperation(ConditionalOperation)
, you can add a kind of
operation tree. Based on the Response#getStatusCode()
of an
IOperation
, the following operation is evaluated and executed. Using
BasicOperationQueue.addOperation(IOperation)
, you can add an IOperation
without
a Condition
, i.e. it is executed right away.ConditionalOperation
s as you like before you start the
execution using BasicOperationQueue.resume()
.IOperation loginOperation = ... IOperation loadPrivileges = ... IOperation reportServerMisconfiguration = ... ConditionalOperation loginCondition = new ConditionalOperation(loginOperation); loginCondition.addOperation(Condition.SUCCESSFUL, loadPrivileges); loginCondition.addOperation(new BasicCondition(404), reportServerMisconfiguration); ConditionalOperationQueue queue = new ConditionalOperationQueue(); queue.addOperation(loginOperation); queue.addConditionalOperation(loginCondition); queue.resume();
Constructor and Description |
---|
ConditionalOperationQueue() |
Modifier and Type | Method and Description |
---|---|
void |
addConditionalOperation(ConditionalOperation conditionalOperation) |
int |
getSize() |
void |
onOperationFailed(IOperation operation)
Notifies this listener that the watched
IOperation failed. |
void |
onOperationFinished(IOperation operation)
Notifies this listener that the watched
IOperation finished. |
void |
reset()
reset the queue as if it were new, i.e.
|
addDelegate, addDelegate, addOperation, addOperations, isIdle, removeDelegate, removeDelegate, resume, suspend
public void reset()
IOperationQueue
reset
in interface IOperationQueue
reset
in class BasicOperationQueue
public int getSize()
getSize
in interface IOperationQueue
getSize
in class BasicOperationQueue
public void addConditionalOperation(ConditionalOperation conditionalOperation)
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.getResponse().getStatusCode()) { caseHttpConnection.HTTP_OK
: break; caseHttpConnection.HTTP_FORBIDDEN
: break; }
onOperationFinished
in interface IOperationDelegate
operation
- The watched IOperation
.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
operation
- The watched IOperation
.