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

The following examples show how to use org.springframework.scheduling.TriggerContext#lastScheduledExecutionTime() . 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: PeriodicTrigger.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Returns the time after which a task should run again.
 */
@Override
public Date nextExecutionTime(TriggerContext triggerContext) {
	if (triggerContext.lastScheduledExecutionTime() == null) {
		return new Date(System.currentTimeMillis() + this.initialDelay);
	}
	else if (this.fixedRate) {
		return new Date(triggerContext.lastScheduledExecutionTime().getTime() + this.period);
	}
	return new Date(triggerContext.lastCompletionTime().getTime() + this.period);
}
 
Example 4
Source File: PeriodicTrigger.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the time after which a task should run again.
 */
@Override
public Date nextExecutionTime(TriggerContext triggerContext) {
	if (triggerContext.lastScheduledExecutionTime() == null) {
		return new Date(System.currentTimeMillis() + this.initialDelay);
	}
	else if (this.fixedRate) {
		return new Date(triggerContext.lastScheduledExecutionTime().getTime() + this.period);
	}
	return new Date(triggerContext.lastCompletionTime().getTime() + this.period);
}