|
|
@@ -35,18 +35,21 @@ public class TaskInformation {
|
|
|
/**
|
|
|
* 两次任务之间的等待时间间隔(毫秒)
|
|
|
*/
|
|
|
- private long period;
|
|
|
+ private long interval;
|
|
|
+
|
|
|
+ private ScheduleType scheduleType;
|
|
|
|
|
|
public TaskInformation() {
|
|
|
super();
|
|
|
}
|
|
|
|
|
|
- public TaskInformation(String title, Executable command, long initialDelay, long period) {
|
|
|
+ public TaskInformation(String title, Executable command, long initialDelay, long interval, ScheduleType scheduleType) {
|
|
|
init();
|
|
|
this.title = title;
|
|
|
this.command = command;
|
|
|
this.initialDelay = initialDelay;
|
|
|
- this.period = period;
|
|
|
+ this.interval = interval;
|
|
|
+ this.scheduleType = scheduleType;
|
|
|
}
|
|
|
|
|
|
public void init(){
|
|
|
@@ -85,12 +88,20 @@ public class TaskInformation {
|
|
|
this.initialDelay = initialDelay;
|
|
|
}
|
|
|
|
|
|
- public long getPeriod() {
|
|
|
- return period;
|
|
|
+ public long getInterval() {
|
|
|
+ return interval;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setInterval(long interval) {
|
|
|
+ this.interval = interval;
|
|
|
+ }
|
|
|
+
|
|
|
+ public ScheduleType getScheduleType() {
|
|
|
+ return scheduleType;
|
|
|
}
|
|
|
|
|
|
- public void setPeriod(long period) {
|
|
|
- this.period = period;
|
|
|
+ public void setScheduleType(ScheduleType scheduleType) {
|
|
|
+ this.scheduleType = scheduleType;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -104,12 +115,42 @@ public class TaskInformation {
|
|
|
TaskInformation other = (TaskInformation) obj;
|
|
|
// command不好比较,不进行比较,也不比较 code
|
|
|
return Objects.equals(title, other.getTitle()) && initialDelay == other.getInitialDelay()
|
|
|
- && period == other.getPeriod();
|
|
|
+ && interval == other.getInterval() && scheduleType == other.getScheduleType();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public String toString() {
|
|
|
- return "TaskInformation [code=" + code + ", title=" + title + ", initialDelay=" + initialDelay + ", period=" + period + "]";
|
|
|
+ return "TaskInformation [code=" + code + ", title=" + title + ", initialDelay=" + initialDelay + ", interval=" + interval + ", scheduleType=" + scheduleType + "]";
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 定时的间隔类型
|
|
|
+ */
|
|
|
+ public enum ScheduleType {
|
|
|
+ /**
|
|
|
+ * Creates and executes a periodic action that becomes enabled first
|
|
|
+ * after the given initial delay, and subsequently with the given
|
|
|
+ * period; that is executions will commence after
|
|
|
+ * <tt>initialDelay</tt> then <tt>initialDelay+period</tt>, then
|
|
|
+ * <tt>initialDelay + 2 * period</tt>, and so on.
|
|
|
+ * If any execution of the task
|
|
|
+ * encounters an exception, subsequent executions are suppressed.
|
|
|
+ * Otherwise, the task will only terminate via cancellation or
|
|
|
+ * termination of the executor. If any execution of this task
|
|
|
+ * takes longer than its period, then subsequent executions
|
|
|
+ * may start late, but will not concurrently execute.
|
|
|
+ */
|
|
|
+ FixedRate,
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Creates and executes a periodic action that becomes enabled first
|
|
|
+ * after the given initial delay, and subsequently with the
|
|
|
+ * given delay between the termination of one execution and the
|
|
|
+ * commencement of the next. If any execution of the task
|
|
|
+ * encounters an exception, subsequent executions are suppressed.
|
|
|
+ * Otherwise, the task will only terminate via cancellation or
|
|
|
+ * termination of the executor.
|
|
|
+ */
|
|
|
+ FixedDelay
|
|
|
+ }
|
|
|
}
|