public abstract class IteratingCallback extends Object implements Callback
process()
where the sub
task is executed and a suitable IteratingCallback.Action
is
returned to this callback to indicate the overall progress of the job.
This callback is passed to the asynchronous execution of each sub
task and a call the succeeded()
on this callback represents
the completion of the sub task.Modifier and Type | Class and Description |
---|---|
protected static class |
IteratingCallback.Action
The indication of the overall progress of the overall job that
implementations of
process() must return. |
Callback.Adapter
Constructor and Description |
---|
IteratingCallback() |
Modifier and Type | Method and Description |
---|---|
protected abstract void |
completed()
Invoked when the overall task has completed successfully.
|
void |
failed(Throwable x)
Invoked when the sub task fails.
|
boolean |
isFailed() |
boolean |
isIdle() |
boolean |
isSucceeded() |
void |
iterate()
This method must be invoked by applications to start the processing
of sub tasks.
|
protected abstract IteratingCallback.Action |
process()
Method called by
iterate() to process the sub task. |
void |
succeeded()
Invoked when the sub task succeeds.
|
String |
toString() |
protected abstract IteratingCallback.Action process() throws Exception
iterate()
to process the sub task.
Implementations must start the asynchronous execution of the sub task
(if any) and return an appropriate action:
IteratingCallback.Action.IDLE
when no sub tasks are available for execution
but the overall job is not completed yetIteratingCallback.Action.SCHEDULED
when the sub task asynchronous execution
has been startedIteratingCallback.Action.SUCCEEDED
when the overall job is completedIteratingCallback.Action.FAILED
when the overall job cannot be completedException
- if the sub task processing throwsprotected abstract void completed()
public void iterate()
process()
returns IteratingCallback.Action.IDLE
, then this method
should be called again to restart processing.
It is safe to call iterate multiple times from multiple threads since only
the first thread to move the state out of INACTIVE will actually do any iteration
and processing.public void succeeded()
super.succeeded()
.succeeded
in interface Callback
Callback.failed(Throwable)
public void failed(Throwable x)
super.failed(Throwable)
.public boolean isIdle()
iterate()
needs to be calledpublic boolean isFailed()
public boolean isSucceeded()
Copyright © 1995-2014 Mort Bay Consulting. All Rights Reserved.