Scheduler.Cancellablepublic static final class Scheduler.ReschedulingRunnable extends AbstractRunnable implements Scheduler.Cancellable
Runnable that needs to be repeated on a interval. For example, checking a value
for cleanup every second could be done by passing in a Runnable that can perform the check and the specified interval between
executions of this runnable. NOTE: the runnable is only rescheduled to run again after completion of the runnable.
For this class, completion means that the call to Runnable.run() returned or an exception was thrown and caught. In
case of an exception, this class will log the exception and reschedule the runnable for its next execution. This differs from the
ScheduledThreadPoolExecutor.scheduleWithFixedDelay(Runnable, long, long, TimeUnit) semantics as an exception there would
terminate the rescheduling of the runnable.| Modifier and Type | Method | Description |
|---|---|---|
void |
cancel() |
Cancel the execution of this object.
|
void |
doRun() |
This method has the same semantics as
Runnable.run() |
boolean |
isCancelled() |
Check if the execution has been cancelled
|
void |
onAfter() |
This method is called in a finally block after successful execution
or on a rejection.
|
void |
onFailure(java.lang.Exception e) |
This method is invoked for all exception thrown by
AbstractRunnable.doRun() |
void |
onRejection(java.lang.Exception e) |
This should be executed if the thread-pool executing this action rejected the execution.
|
isForceExecution, runpublic void cancel()
Scheduler.Cancellablecancel in interface Scheduler.Cancellablepublic boolean isCancelled()
Scheduler.CancellableisCancelled in interface Scheduler.Cancellablepublic void doRun()
AbstractRunnableRunnable.run()doRun in class AbstractRunnablepublic void onFailure(java.lang.Exception e)
AbstractRunnableAbstractRunnable.doRun()onFailure in class AbstractRunnablepublic void onRejection(java.lang.Exception e)
AbstractRunnableAbstractRunnable.onFailure(Exception)onRejection in class AbstractRunnablepublic void onAfter()
AbstractRunnableonAfter in class AbstractRunnable