Spring Framework TriggerContext - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework TriggerContext class.

This code example shows how to use the following methods:lastCompletionTime, lastScheduledExecutionTime
	 * {@linkplain TriggerContext#lastCompletionTime completion time} of the 
	 * previous execution; therefore, overlapping executions won't occur. 
	 */ 
	@Override 
	public Date nextExecutionTime(TriggerContext triggerContext) {
		Date date = triggerContext.lastCompletionTime();
		if (date != null) {
			Date scheduled = triggerContext.lastScheduledExecutionTime();
			if (scheduled != null && date.before(scheduled)) {
				// Previous task apparently executed too early... 
				// Let's simply use the last calculated execution time then, 
				// in order to prevent accidental re-fires in the same second. 
				date = scheduled;
			} 
		} 
		else { 
			date = new Date();
		} 
		return this.sequenceGenerator.next(date);
	} 
6
CodeRank
This code example shows how to use the following methods:lastCompletionTime, lastScheduledExecutionTime
	/** 
	 * 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);
	} 
 
 
	@Override 
	public boolean equals(Object obj) {
		if (this == obj) {
			return true; 
		} 
6
CodeRank
See Code Examples for Spring Framework TriggerContext Methods: