Example usage for org.springframework.scheduling TriggerContext lastCompletionTime

List of usage examples for org.springframework.scheduling TriggerContext lastCompletionTime

Introduction

In this page you can find the example usage for org.springframework.scheduling TriggerContext lastCompletionTime.

Prototype

@Nullable
Date lastCompletionTime();

Source Link

Document

Return the last completion time of the task, or null if not scheduled before.

Usage

From source file:fr.mael.microrss.service.impl.ParseTrigger.java

@Override
public Date nextExecutionTime(TriggerContext triggerContext) {
    Date lastDate = triggerContext.lastCompletionTime();
    if (lastDate == null) {
        lastDate = new Date();
    }//from  w  ww .  j a v a2s.  c o m
    Date newDate = new Date();
    newDate.setTime(lastDate.getTime() + EXECUTION_INTERVAL);
    return newDate;
}

From source file:uk.ac.bbsrc.tgac.miso.notification.core.DynamicTrigger.java

/**
 * Returns the time after which a task should run again.
 *///from  www  .j a v a 2 s.com
public Date nextExecutionTime(TriggerContext triggerContext) {
    log.debug("lastScheduledExecutionTime::" + triggerContext.lastScheduledExecutionTime());
    if (triggerContext.lastScheduledExecutionTime() == null) {
        log.debug("nextExecutionTime::" + new Date(System.currentTimeMillis() + this.initialDelay));
        return new Date(System.currentTimeMillis() + this.initialDelay);
    } else if (this.fixedRate) {
        log.debug("nextExecutionTime::"
                + new Date(triggerContext.lastScheduledExecutionTime().getTime() + this.period));
        return new Date(triggerContext.lastScheduledExecutionTime().getTime() + this.period);
    }
    log.debug("nextExecutionTime::" + new Date(triggerContext.lastCompletionTime().getTime() + this.period));
    return new Date(triggerContext.lastCompletionTime().getTime() + this.period);
}