Java Code Examples for org.springframework.scheduling.TriggerContext#lastCompletionTime()

The following examples show how to use org.springframework.scheduling.TriggerContext#lastCompletionTime() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PeriodicTrigger.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Returns the time after which a task should run again.
 */
@Override
public Date nextExecutionTime(TriggerContext triggerContext) {
	Date lastExecution = triggerContext.lastScheduledExecutionTime();
	Date lastCompletion = triggerContext.lastCompletionTime();
	if (lastExecution == null || lastCompletion == null) {
		return new Date(System.currentTimeMillis() + this.initialDelay);
	}
	if (this.fixedRate) {
		return new Date(lastExecution.getTime() + this.period);
	}
	return new Date(lastCompletion.getTime() + this.period);
}
 
Example 2
Source File: PeriodicTrigger.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Returns the time after which a task should run again.
 */
@Override
public Date nextExecutionTime(TriggerContext triggerContext) {
	Date lastExecution = triggerContext.lastScheduledExecutionTime();
	Date lastCompletion = triggerContext.lastCompletionTime();
	if (lastExecution == null || lastCompletion == null) {
		return new Date(System.currentTimeMillis() + this.initialDelay);
	}
	if (this.fixedRate) {
		return new Date(lastExecution.getTime() + this.period);
	}
	return new Date(lastCompletion.getTime() + this.period);
}
 
Example 3
Source File: ScheduledConfig2.java    From SpringBoot2.0 with Apache License 2.0 4 votes vote down vote up
@Override
public Date nextExecutionTime(TriggerContext triggerContext) {
    Date date = triggerContext.lastCompletionTime();
    return new Date(date == null ? new Date().getTime() : date.getTime() + 5000);
}