org.springframework.scheduling.concurrent
Class ReschedulingRunnable
java.lang.Object
org.springframework.scheduling.support.DelegatingErrorHandlingRunnable
org.springframework.scheduling.concurrent.ReschedulingRunnable
- All Implemented Interfaces:
- java.lang.Comparable<java.util.concurrent.Delayed>, java.lang.Runnable, java.util.concurrent.Delayed, java.util.concurrent.Future<java.lang.Object>, java.util.concurrent.ScheduledFuture<java.lang.Object>
class ReschedulingRunnable
- extends DelegatingErrorHandlingRunnable
- implements java.util.concurrent.ScheduledFuture<java.lang.Object>
Internal adapter that reschedules an underlying 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).
- Since:
- 3.0
- Author:
- Juergen Hoeller, Mark Fisher
|
Method Summary |
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()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
trigger
private final Trigger trigger
triggerContext
private final SimpleTriggerContext triggerContext
executor
private final java.util.concurrent.ScheduledExecutorService executor
currentFuture
private volatile java.util.concurrent.ScheduledFuture currentFuture
scheduledExecutionTime
private volatile java.util.Date scheduledExecutionTime
triggerContextMonitor
private final java.lang.Object triggerContextMonitor
ReschedulingRunnable
public ReschedulingRunnable(java.lang.Runnable delegate,
Trigger trigger,
java.util.concurrent.ScheduledExecutorService executor,
ErrorHandler errorHandler)
schedule
public java.util.concurrent.ScheduledFuture schedule()
run
public void run()
- Specified by:
run in interface java.lang.Runnable- Overrides:
run in class DelegatingErrorHandlingRunnable
cancel
public boolean cancel(boolean mayInterruptIfRunning)
- Specified by:
cancel in interface java.util.concurrent.Future<java.lang.Object>
isCancelled
public boolean isCancelled()
- Specified by:
isCancelled in interface java.util.concurrent.Future<java.lang.Object>
isDone
public boolean isDone()
- Specified by:
isDone in interface java.util.concurrent.Future<java.lang.Object>
get
public java.lang.Object get()
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException
- Specified by:
get in interface java.util.concurrent.Future<java.lang.Object>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
get
public java.lang.Object get(long timeout,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException,
java.util.concurrent.ExecutionException,
java.util.concurrent.TimeoutException
- Specified by:
get in interface java.util.concurrent.Future<java.lang.Object>
- Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException
java.util.concurrent.TimeoutException
getDelay
public long getDelay(java.util.concurrent.TimeUnit unit)
- Specified by:
getDelay in interface java.util.concurrent.Delayed
compareTo
public int compareTo(java.util.concurrent.Delayed other)
- Specified by:
compareTo in interface java.lang.Comparable<java.util.concurrent.Delayed>