Search in sources :

Example 1 with TriggerCallable

use of org.apache.openejb.threads.task.TriggerCallable in project tomee by apache.

the class ManagedScheduledExecutorServiceImpl method schedule.

@Override
public <V> ScheduledFuture<V> schedule(final Callable<V> vCallable, final Trigger trigger) {
    final Date taskScheduledTime = new Date();
    final AtomicReference<Future<V>> futureHandle = new AtomicReference<Future<V>>();
    final TriggerCallable<V> wrapper = new TriggerCallable<>(this, vCallable, new CUCallable<>(vCallable), trigger, taskScheduledTime, getTaskId(vCallable), futureHandle);
    final ScheduledFuture<V> future = delegate.schedule(wrapper, trigger.getNextRunTime(wrapper.getLastExecution(), taskScheduledTime).getTime() - nowMs(), TimeUnit.MILLISECONDS);
    return initTriggerScheduledFuture(vCallable, futureHandle, wrapper, future);
}
Also used : TriggerCallable(org.apache.openejb.threads.task.TriggerCallable) CUScheduleFuture(org.apache.openejb.threads.future.CUScheduleFuture) ScheduledFuture(java.util.concurrent.ScheduledFuture) Future(java.util.concurrent.Future) AtomicReference(java.util.concurrent.atomic.AtomicReference) Date(java.util.Date)

Aggregations

Date (java.util.Date)1 Future (java.util.concurrent.Future)1 ScheduledFuture (java.util.concurrent.ScheduledFuture)1 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 CUScheduleFuture (org.apache.openejb.threads.future.CUScheduleFuture)1 TriggerCallable (org.apache.openejb.threads.task.TriggerCallable)1