Created
April 20, 2017 14:43
-
-
Save silmeth/84d6cace69dffc31e26284da9799915e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.Instant; | |
import com.github.kagkarlsson.scheduler.task.CompletionHandler; | |
import com.github.kagkarlsson.scheduler.task.ExecutionComplete; | |
import com.github.kagkarlsson.scheduler.task.ExecutionOperations; | |
import com.github.kagkarlsson.scheduler.task.Schedule; | |
import org.slf4j.Logger; | |
import org.slf4j.LoggerFactory; | |
public final class OnCompleteRescheduleByPreviousExecution implements CompletionHandler { | |
private static final Logger LOG = LoggerFactory.getLogger(OnCompleteRescheduleByPreviousExecution.class); | |
private final Schedule schedule; | |
OnCompleteRescheduleByPreviousExecution(Schedule schedule) { | |
this.schedule = schedule; | |
} | |
@Override | |
public void complete(ExecutionComplete executionComplete, ExecutionOperations executionOperations) { | |
Instant nextExecution = schedule.getNextExecutionTime(executionComplete.getExecution().getExecutionTime()); | |
LOG.debug("Rescheduling task {} to {}", executionComplete.getExecution().taskInstance, nextExecution); | |
executionOperations.reschedule(executionComplete, nextExecution); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment