下面列出了org.quartz.SimpleScheduleBuilder#withMisfireHandlingInstructionNowWithExistingCount ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private SimpleScheduleBuilder handleSimpleScheduleMisfirePolicy(TaskInfo.TriggerInfo triggerInfo,
SimpleScheduleBuilder sb) throws TaskException {
switch (triggerInfo.getMisfirePolicy()) {
case DEFAULT:
return sb;
case FIRE_NOW:
return sb.withMisfireHandlingInstructionFireNow();
case IGNORE_MISFIRES:
return sb.withMisfireHandlingInstructionIgnoreMisfires();
case NEXT_WITH_EXISTING_COUNT:
return sb.withMisfireHandlingInstructionNextWithExistingCount();
case NEXT_WITH_REMAINING_COUNT:
return sb.withMisfireHandlingInstructionNextWithRemainingCount();
case NOW_WITH_EXISTING_COUNT:
return sb.withMisfireHandlingInstructionNowWithExistingCount();
case NOW_WITH_REMAINING_COUNT:
return sb.withMisfireHandlingInstructionNowWithRemainingCount();
default:
throw new TaskException("The task misfire policy '" + triggerInfo.getMisfirePolicy()
+ "' cannot be used in simple schedule tasks",
TaskException.Code.CONFIG_ERROR);
}
}
/**
* Get a {@link ScheduleBuilder} that is configured to produce a
* schedule identical to this trigger's schedule.
*
* @see #getTriggerBuilder()
*/
@Override
public ScheduleBuilder<SimpleTrigger> getScheduleBuilder() {
SimpleScheduleBuilder sb = SimpleScheduleBuilder.simpleSchedule()
.withIntervalInMilliseconds(getRepeatInterval())
.withRepeatCount(getRepeatCount());
switch(getMisfireInstruction()) {
case MISFIRE_INSTRUCTION_FIRE_NOW : sb.withMisfireHandlingInstructionFireNow();
break;
case MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_EXISTING_COUNT : sb.withMisfireHandlingInstructionNextWithExistingCount();
break;
case MISFIRE_INSTRUCTION_RESCHEDULE_NEXT_WITH_REMAINING_COUNT : sb.withMisfireHandlingInstructionNextWithRemainingCount();
break;
case MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_EXISTING_REPEAT_COUNT : sb.withMisfireHandlingInstructionNowWithExistingCount();
break;
case MISFIRE_INSTRUCTION_RESCHEDULE_NOW_WITH_REMAINING_REPEAT_COUNT : sb.withMisfireHandlingInstructionNowWithRemainingCount();
break;
}
return sb;
}