Java 类org.quartz.spi.MutableTrigger 实例源码

项目:lams    文件:TriggerBuilder.java   
/**
 * Produce the <code>Trigger</code>.
 * 
 * @return a Trigger that meets the specifications of the builder.
 */
@SuppressWarnings("unchecked")
public T build() {

    if(scheduleBuilder == null)
        scheduleBuilder = SimpleScheduleBuilder.simpleSchedule();
    MutableTrigger trig = scheduleBuilder.build();

    trig.setCalendarName(calendarName);
    trig.setDescription(description);
    trig.setStartTime(startTime);
    trig.setEndTime(endTime);
    if(key == null)
        key = new TriggerKey(Key.createUniqueName(null), null);
    trig.setKey(key); 
    if(jobKey != null)
        trig.setJobKey(jobKey);
    trig.setPriority(priority);

    if(!jobDataMap.isEmpty())
        trig.setJobDataMap(jobDataMap);

    return (T) trig;
}
项目:hsweb-framework    文件:SimpleScheduleJobService.java   
protected void startJob(ScheduleJobEntity jobEntity) {
    try {
    if(scheduler.checkExists(createJobKey(jobEntity))) {
        return;
    }
    JobDetail jobDetail = JobBuilder
            .newJob(DynamicJob.class)
            .withIdentity(createJobKey(jobEntity))
            .setJobData(createJobDataMap(jobEntity.getParameters()))
            .usingJobData(DynamicJobFactory.JOB_ID_KEY, jobEntity.getId())
            .withDescription(jobEntity.getName() + (jobEntity.getRemark() == null ? "" : jobEntity.getRemark()))
            .build();
    MutableTrigger trigger = scheduleTriggerBuilder.buildTrigger(jobEntity.getQuartzConfig());
    trigger.setKey(createTriggerKey(jobEntity));

        scheduler.scheduleJob(jobDetail, trigger);
    } catch (SchedulerException e) {
        throw new BusinessException("启动定时调度失败", e);
    }
}
项目:logsniffer    文件:SnifferJobManager.java   
@Override
@Transactional(rollbackFor = { SchedulerException.class, ParseException.class })
public void startSniffing(final long snifferId) throws SchedulerException {
    logger.debug("Starting cron job for sniffer: {}", snifferId);
    final Sniffer sniffer = snifferPersistence.getSniffer(snifferId);
    if (sniffer == null) {
        throw new SchedulerException("Sniffer not found: " + snifferId);
    }
    stopAndDeleteAllSnifferJobs(sniffer.getId());
    MutableTrigger trigger;
    try {
        trigger = CronScheduleBuilder.cronScheduleNonvalidatedExpression(sniffer.getScheduleCronExpression())
                .withMisfireHandlingInstructionDoNothing().build();
    } catch (final ParseException e) {
        throw new SchedulerException("Failed to parse cron expression", e);
    }
    trigger.setKey(getKey(sniffer, sniffer.getLogSourceId()));
    final JobDetail jobDetail = JobBuilder.newJob(SnifferJob.class).requestRecovery()
            .withIdentity(getJobKey(sniffer, sniffer.getLogSourceId())).build();
    scheduler.scheduleJob(jobDetail, trigger);
    final ScheduleInfo scheduleInfo = scheduleInfoAccess.getScheduleInfo(snifferId);
    scheduleInfo.setScheduled(true);
    scheduleInfoAccess.updateScheduleInfo(snifferId, scheduleInfo);
    logger.info("Scheduled cron job for sniffer {} and log source {} with trigger {}", sniffer,
            sniffer.getLogSourceId(), trigger);
}
项目:lams    文件:SimpleScheduleBuilder.java   
/**
 * Build the actual Trigger -- NOT intended to be invoked by end users,
 * but will rather be invoked by a TriggerBuilder which this 
 * ScheduleBuilder is given to.
 * 
 * @see TriggerBuilder#withSchedule(ScheduleBuilder)
 */
@Override
public MutableTrigger build() {

    SimpleTriggerImpl st = new SimpleTriggerImpl();
    st.setRepeatInterval(interval);
    st.setRepeatCount(repeatCount);
    st.setMisfireInstruction(misfireInstruction);

    return st;
}
项目:lams    文件:XMLSchedulingDataProcessor.java   
private Map<JobKey, List<MutableTrigger>> buildTriggersByFQJobNameMap(List<MutableTrigger> triggers) {

    Map<JobKey, List<MutableTrigger>> triggersByFQJobName = new HashMap<JobKey, List<MutableTrigger>>();

    for(MutableTrigger trigger: triggers) {
        List<MutableTrigger> triggersOfJob = triggersByFQJobName.get(trigger.getJobKey());
        if(triggersOfJob == null) {
            triggersOfJob = new LinkedList<MutableTrigger>();
            triggersByFQJobName.put(trigger.getJobKey(), triggersOfJob);
        }
        triggersOfJob.add(trigger);
    }

    return triggersByFQJobName;
}
项目:lams    文件:CronScheduleBuilder.java   
/**
 * Build the actual Trigger -- NOT intended to be invoked by end users, but
 * will rather be invoked by a TriggerBuilder which this ScheduleBuilder is
 * given to.
 * 
 * @see TriggerBuilder#withSchedule(ScheduleBuilder)
 */
@Override
public MutableTrigger build() {

    CronTriggerImpl ct = new CronTriggerImpl();

    ct.setCronExpression(cronExpression);
    ct.setTimeZone(cronExpression.getTimeZone());
    ct.setMisfireInstruction(misfireInstruction);

    return ct;
}
项目:lams    文件:DailyTimeIntervalScheduleBuilder.java   
/**
 * Build the actual Trigger -- NOT intended to be invoked by end users,
 * but will rather be invoked by a TriggerBuilder which this 
 * ScheduleBuilder is given to.
 * 
 * @see TriggerBuilder#withSchedule(ScheduleBuilder)
 */
@Override
public MutableTrigger build() {

    DailyTimeIntervalTriggerImpl st = new DailyTimeIntervalTriggerImpl();
    st.setRepeatInterval(interval);
    st.setRepeatIntervalUnit(intervalUnit);
    st.setMisfireInstruction(misfireInstruction);
    st.setRepeatCount(repeatCount);

    if(daysOfWeek != null)
        st.setDaysOfWeek(daysOfWeek);
    else
        st.setDaysOfWeek(ALL_DAYS_OF_THE_WEEK);

    if(startTimeOfDay != null)
        st.setStartTimeOfDay(startTimeOfDay);
    else
        st.setStartTimeOfDay(TimeOfDay.hourAndMinuteOfDay(0, 0));

    if(endTimeOfDay != null)
        st.setEndTimeOfDay(endTimeOfDay);
    else
        st.setEndTimeOfDay(TimeOfDay.hourMinuteAndSecondOfDay(23, 59, 59));

    return st;
}
项目:lams    文件:CalendarIntervalScheduleBuilder.java   
/**
 * Build the actual Trigger -- NOT intended to be invoked by end users,
 * but will rather be invoked by a TriggerBuilder which this 
 * ScheduleBuilder is given to.
 * 
 * @see TriggerBuilder#withSchedule(ScheduleBuilder)
 */
@Override
public MutableTrigger build() {

    CalendarIntervalTriggerImpl st = new CalendarIntervalTriggerImpl();
    st.setRepeatInterval(interval);
    st.setRepeatIntervalUnit(intervalUnit);
    st.setMisfireInstruction(misfireInstruction);
    st.setTimeZone(timeZone);
    st.setPreserveHourOfDayAcrossDaylightSavings(preserveHourOfDayAcrossDaylightSavings);
    st.setSkipDayIfHourDoesNotExist(skipDayIfHourDoesNotExist);

    return st;
}
项目:hsweb-framework    文件:SmartScheduleTriggerBuilder.java   
@Override
public MutableTrigger buildTrigger(String config) {
    JSONObject configObj = JSON.parseObject(config);
    switch (configObj.getString("type")) {
        case "cron":
            String cron = configObj.getString("config");
            return CronScheduleBuilder.cronSchedule(cron)
                    .build();
        default:
            throw new UnsupportedOperationException(config);
    }

}
项目:Fenzo    文件:IntervalTrigger.java   
@Override
@JsonIgnore
public ScheduleBuilder getScheduleBuilder() {
    return new ScheduleBuilder<SimpleTrigger>() {
        @Override
        protected MutableTrigger build() {
            return SimpleScheduleBuilder.simpleSchedule()
                    .withRepeatCount(repeatCount)
                    .withIntervalInMilliseconds(repeatInterval)
                    .withMisfireHandlingInstructionNextWithRemainingCount()
                    .build();
        }
    };
}
项目:motech    文件:PeriodIntervalScheduleBuilder.java   
/**
 * Build the actual Trigger -- NOT intended to be invoked by end users,
 * but will rather be invoked by a TriggerBuilder which this
 * ScheduleBuilder is given to.
 */
@Override
public MutableTrigger build() {

    PeriodIntervalTriggerImpl pt = new PeriodIntervalTriggerImpl();
    pt.setRepeatPeriod(repeatPeriod);
    pt.setMisfireInstruction(misfireInstruction);

    return pt;
}
项目:lams    文件:XMLSchedulingDataProcessor.java   
protected void addTriggerToSchedule(MutableTrigger trigger) {
    loadedTriggers.add(trigger);
}
项目:taboola-cronyx    文件:OnDemandScheduleBuilder.java   
@Override
protected MutableTrigger build() {
    OnDemandTrigger onDemandTrigger = new OnDemandTrigger();
    onDemandTrigger.setMisfireInstruction(MISFIRE_INSTRUCTION_FIRE_NOW);
    return onDemandTrigger;
}
项目:lams    文件:XMLSchedulingDataProcessor.java   
/**
 * Returns a <code>List</code> of triggers loaded from the xml file.
 * <p/>
 * 
 * @return a <code>List</code> of triggers.
 */
protected List<MutableTrigger> getLoadedTriggers() {
    return Collections.unmodifiableList(loadedTriggers);
}
项目:lams    文件:ScheduleBuilder.java   
protected abstract MutableTrigger build();
项目:hsweb-framework    文件:ScheduleTriggerBuilder.java   
MutableTrigger buildTrigger(String config);