Java 类org.quartz.CalendarIntervalTrigger 实例源码

项目:lams    文件:CalendarIntervalTriggerImpl.java   
/**
 * Get a {@link ScheduleBuilder} that is configured to produce a 
 * schedule identical to this trigger's schedule.
 * 
 * @see #getTriggerBuilder()
 */
@Override
public ScheduleBuilder<CalendarIntervalTrigger> getScheduleBuilder() {

    CalendarIntervalScheduleBuilder cb = CalendarIntervalScheduleBuilder.calendarIntervalSchedule()
            .withInterval(getRepeatInterval(), getRepeatIntervalUnit());

    switch(getMisfireInstruction()) {
        case MISFIRE_INSTRUCTION_DO_NOTHING : cb.withMisfireHandlingInstructionDoNothing();
        break;
        case MISFIRE_INSTRUCTION_FIRE_ONCE_NOW : cb.withMisfireHandlingInstructionFireAndProceed();
        break;
    }

    return cb;
}
项目:motech    文件:SchedulableJobBuilder.java   
private static SchedulableJob buildRepeatingSchedulableJob(Trigger trigger, JobDataMap dataMap) {
    RepeatingSchedulableJob job = new RepeatingSchedulableJob();
    long interval;

    if (trigger instanceof CalendarIntervalTrigger) {
        CalendarIntervalTrigger calendarTrigger = (CalendarIntervalTrigger) trigger;
        interval = calendarTrigger.getRepeatInterval();
    } else {
        SimpleTrigger simpleTrigger = (SimpleTrigger) trigger;
        job.setRepeatCount(simpleTrigger.getRepeatCount());
        interval = simpleTrigger.getRepeatInterval() / SECOND;
    }

    job.setEndDate(getEndDate(trigger));
    job.setRepeatIntervalInSeconds((int) interval);
    job.setIgnorePastFiresAtStart(dataMap.getBoolean(IGNORE_PAST_FIRES_AT_START));
    job.setUseOriginalFireTimeAfterMisfire(dataMap.getBoolean(USE_ORIGINAL_FIRE_TIME_AFTER_MISFIRE));

    return job;
}
项目:jooby    文件:QuartzProvider.java   
private Object describe(final Trigger trigger) {
  if (trigger.getDescription() != null) {
    return trigger.getDescription();
  }
  if (trigger instanceof SimpleTrigger) {
    return "will fire every " + ((SimpleTrigger) trigger).getRepeatInterval() + "ms";
  }
  if (trigger instanceof CronTrigger) {
    return "will fire at " + ((CronTrigger) trigger).getCronExpression();
  }
  if (trigger instanceof CalendarIntervalTrigger) {
    CalendarIntervalTrigger calendar = (CalendarIntervalTrigger) trigger;
    return "will fire every " + calendar.getRepeatInterval() + " "
        + calendar.getRepeatIntervalUnit();
  }
  if (trigger instanceof DailyTimeIntervalTrigger) {
    DailyTimeIntervalTrigger daily = (DailyTimeIntervalTrigger) trigger;
    return "will fire every " + daily.getRepeatInterval() + " "
        + daily.getRepeatIntervalUnit();
  }
  return trigger;
}
项目:motech    文件:MotechSchedulerDatabaseServiceImpl.java   
private String getJobInfo(Trigger trigger, String jobType) throws SchedulerException {
    if (jobType.equals(JobBasicInfo.JOBTYPE_REPEATING)) {
        Integer timesTriggered = 0;
        String repeatMaxCount = "-";

        if (trigger instanceof CalendarIntervalTrigger) {
            CalendarIntervalTrigger calendarIntervalTrigger = (CalendarIntervalTrigger) trigger;

            timesTriggered = calendarIntervalTrigger.getTimesTriggered();
        } else if (trigger instanceof SimpleTrigger) {
            SimpleTrigger simpleTrigger = (SimpleTrigger) trigger;

            timesTriggered = simpleTrigger.getTimesTriggered();
        }

        if (trigger.getEndTime() != null) {
            repeatMaxCount = Integer.toString(TriggerUtils.computeFireTimesBetween(
                    (OperableTrigger) trigger, null, trigger.getStartTime(), trigger.getEndTime()
            ).size() + timesTriggered);
        }

        return String.format("%d/%s", timesTriggered, repeatMaxCount);
    } else if (jobType.equals(JobBasicInfo.JOBTYPE_CRON)) {
        CronScheduleBuilder cronScheduleBuilder = (CronScheduleBuilder) trigger.getScheduleBuilder();

        CronTrigger cronTrigger = (CronTrigger) cronScheduleBuilder.build();

        return cronTrigger.getCronExpression();
    } else {
        return "-";
    }
}