class ReschedulingRunnable extends DelegatingErrorHandlingRunnable implements java.util.concurrent.ScheduledFuture<java.lang.Object>
Runnable
according
to the next execution time suggested by a given Trigger
.
Necessary because a native ScheduledExecutorService
supports
delay-driven execution only. The flexibility of the Trigger
interface
will be translated onto a delay for the next execution time (repeatedly).
Modifier and Type | Field and Description |
---|---|
private java.util.concurrent.ScheduledFuture<?> |
currentFuture |
private java.util.concurrent.ScheduledExecutorService |
executor |
private java.util.Date |
scheduledExecutionTime |
private Trigger |
trigger |
private SimpleTriggerContext |
triggerContext |
private java.lang.Object |
triggerContextMonitor |
Constructor and Description |
---|
ReschedulingRunnable(java.lang.Runnable delegate,
Trigger trigger,
java.util.concurrent.ScheduledExecutorService executor,
ErrorHandler errorHandler) |
Modifier and Type | Method and Description |
---|---|
boolean |
cancel(boolean mayInterruptIfRunning) |
int |
compareTo(java.util.concurrent.Delayed other) |
java.lang.Object |
get() |
java.lang.Object |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
long |
getDelay(java.util.concurrent.TimeUnit unit) |
boolean |
isCancelled() |
boolean |
isDone() |
void |
run() |
java.util.concurrent.ScheduledFuture<?> |
schedule() |
toString
private final Trigger trigger
private final SimpleTriggerContext triggerContext
private final java.util.concurrent.ScheduledExecutorService executor
private java.util.concurrent.ScheduledFuture<?> currentFuture
private java.util.Date scheduledExecutionTime
private final java.lang.Object triggerContextMonitor
public ReschedulingRunnable(java.lang.Runnable delegate, Trigger trigger, java.util.concurrent.ScheduledExecutorService executor, ErrorHandler errorHandler)
public java.util.concurrent.ScheduledFuture<?> schedule()
public void run()
run
in interface java.lang.Runnable
run
in class DelegatingErrorHandlingRunnable
public boolean cancel(boolean mayInterruptIfRunning)
cancel
in interface java.util.concurrent.Future<java.lang.Object>
public boolean isCancelled()
isCancelled
in interface java.util.concurrent.Future<java.lang.Object>
public boolean isDone()
isDone
in interface java.util.concurrent.Future<java.lang.Object>
public java.lang.Object get() throws java.lang.InterruptedException, java.util.concurrent.ExecutionException
get
in interface java.util.concurrent.Future<java.lang.Object>
java.lang.InterruptedException
java.util.concurrent.ExecutionException
public java.lang.Object get(long timeout, java.util.concurrent.TimeUnit unit) throws java.lang.InterruptedException, java.util.concurrent.ExecutionException, java.util.concurrent.TimeoutException
get
in interface java.util.concurrent.Future<java.lang.Object>
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
public long getDelay(java.util.concurrent.TimeUnit unit)
getDelay
in interface java.util.concurrent.Delayed
public int compareTo(java.util.concurrent.Delayed other)
compareTo
in interface java.lang.Comparable<java.util.concurrent.Delayed>