• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ScheduleBuilder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.quartz.ScheduleBuilder的典型用法代码示例。如果您正苦于以下问题:Java ScheduleBuilder类的具体用法?Java ScheduleBuilder怎么用?Java ScheduleBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ScheduleBuilder类属于org.quartz包,在下文中一共展示了ScheduleBuilder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getTriggerPropertyBundle

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
@Override
protected TriggerPropertyBundle getTriggerPropertyBundle(SimplePropertiesTriggerProperties props) {

    TimeZone tz = null; // if we use null, that's ok as system default tz will be used
    String tzId = props.getString2();
    if(tzId != null && tzId.trim().length() != 0) // there could be null entries from previously released versions
        tz = TimeZone.getTimeZone(tzId);
    
    ScheduleBuilder<?> sb = CalendarIntervalScheduleBuilder.calendarIntervalSchedule()
        .withInterval(props.getInt1(), IntervalUnit.valueOf(props.getString1()))
        .inTimeZone(tz)
        .preserveHourOfDayAcrossDaylightSavings(props.isBoolean1())
        .skipDayIfHourDoesNotExist(props.isBoolean2());
    
    int timesTriggered = props.getInt2();
    
    String[] statePropertyNames = { "timesTriggered" };
    Object[] statePropertyValues = { timesTriggered };

    return new TriggerPropertyBundle(sb, statePropertyNames, statePropertyValues);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:CalendarIntervalTriggerPersistenceDelegate.java


示例2: getScheduleBuilder

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
/**
 * Get a {@link ScheduleBuilder} that is configured to produce a 
 * schedule identical to this trigger's schedule.
 * 
 * @see #getTriggerBuilder()
 */
@Override
public ScheduleBuilder<CronTrigger> getScheduleBuilder() {
    
    CronScheduleBuilder cb = CronScheduleBuilder.cronSchedule(getCronExpression())
            .inTimeZone(getTimeZone());
        
    switch(getMisfireInstruction()) {
        case MISFIRE_INSTRUCTION_DO_NOTHING : cb.withMisfireHandlingInstructionDoNothing();
        break;
        case MISFIRE_INSTRUCTION_FIRE_ONCE_NOW : cb.withMisfireHandlingInstructionFireAndProceed();
        break;
    }
    
    return cb;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:CronTriggerImpl.java


示例3: getScheduleBuilder

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
/**
 * Get a {@link ScheduleBuilder} that is configured to produce a 
 * schedule identical to this trigger's schedule.
 * 
 * @see #getTriggerBuilder()
 */
@Override
public ScheduleBuilder<DailyTimeIntervalTrigger> getScheduleBuilder() {
    
    DailyTimeIntervalScheduleBuilder cb = DailyTimeIntervalScheduleBuilder.dailyTimeIntervalSchedule()
            .withInterval(getRepeatInterval(), getRepeatIntervalUnit())
            .onDaysOfTheWeek(getDaysOfWeek()).startingDailyAt(getStartTimeOfDay()).endingDailyAt(getEndTimeOfDay());
        
    switch(getMisfireInstruction()) {
        case MISFIRE_INSTRUCTION_DO_NOTHING : cb.withMisfireHandlingInstructionDoNothing();
        break;
        case MISFIRE_INSTRUCTION_FIRE_ONCE_NOW : cb.withMisfireHandlingInstructionFireAndProceed();
        break;
    }
    
    return cb;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:23,代码来源:DailyTimeIntervalTriggerImpl.java


示例4: getScheduleBuilder

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:CalendarIntervalTriggerImpl.java


示例5: getScheduleBuilder

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:29,代码来源:SimpleTriggerImpl.java


示例6: parseAtExpr

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
private ScheduleBuilder<? extends Trigger> parseAtExpr(String atExpr) {
    Matcher matcher = AT_EXPR_PATTERN.matcher(atExpr);
    if (!matcher.find()) {
        throwException(atExpr);
    }

    if (matcher.group(1).equals("??")) {
        String cronExpression = "0 " + matcher.group(2) + " * * * ?";
        return parseCron(cronExpression);
    }

    val formatter = DateTimeFormat.forPattern("HH:mm");
    val dateTime = formatter.parseDateTime(matcher.group().trim());

    int hourOfDay = dateTime.getHourOfDay();
    int minuteOfHour = dateTime.getMinuteOfHour();

    return dailyAtHourAndMinute(hourOfDay, minuteOfHour);
}
 
开发者ID:bingoohuang,项目名称:westcache,代码行数:20,代码来源:ScheduledParser.java


示例7: parseEveryExpr

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
private ScheduleBuilder<? extends Trigger> parseEveryExpr(String everyExpr) {
    Matcher matcher = EVERY_EXPR_PATTERN.matcher(everyExpr);
    if (!matcher.find())
        return throwException(everyExpr);

    int num = Integer.parseInt(matcher.group(1));
    if (num <= 0)
        throwException(everyExpr);

    char unit = matcher.group(2).charAt(0);
    TimeUnit timeUnit = parseTimeUnit(unit);

    return simpleSchedule()
            .withIntervalInSeconds((int) timeUnit.toSeconds(num))
            .repeatForever();
}
 
开发者ID:bingoohuang,项目名称:westcache,代码行数:17,代码来源:ScheduledParser.java


示例8: testAcquireNextTriggerAfterMissFire_doesNotTrigger_ifNextScheduleTimeOutOfRange

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
@Test
public void testAcquireNextTriggerAfterMissFire_doesNotTrigger_ifNextScheduleTimeOutOfRange()
  throws Exception {

  long baseFireTime = newDate().build().getTime();

  JobDetail job = JobBuilder.newJob(NoOpJob.class).build();
  jobStore.storeJob(job, true);

  ScheduleBuilder scheduleBuilder = simpleSchedule().withIntervalInSeconds(3).repeatForever()
      .withMisfireHandlingInstructionNextWithExistingCount();
  OperableTrigger t1 = buildAndComputeTrigger("trigger1", "triggerGroup1", job, baseFireTime + 500, null,
      scheduleBuilder);
  jobStore.storeTrigger(t1, false);

  assertAcquiredAndRelease(baseFireTime, 1);

  Thread.sleep(5000);
  // missed one execution (3 seconds tick is more than 1 seconds ago), next execution (at 6 seconds tick) is not yet picked up
  assertAcquiredAndRelease(newDate().build().getTime() + 250, 0);

  // try acquire on larger interval (containing 6 sec tick)
  assertAcquiredAndRelease(newDate().build().getTime() + 1550, 1);

}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:26,代码来源:HazelcastJobStoreTest.java


示例9: buildTrigger

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
protected OperableTrigger buildTrigger(String triggerName,
    String triggerGroup,
    JobDetail job,
    Long startAt,
    Long endAt,
    ScheduleBuilder scheduleBuilder) {

  ScheduleBuilder schedule = scheduleBuilder!=null?scheduleBuilder : SimpleScheduleBuilder.simpleSchedule();
  return (OperableTrigger) TriggerBuilder
      .newTrigger()
      .withIdentity(triggerName, triggerGroup)
      .forJob(job)
      .startAt(startAt != null ? new Date(startAt) : null)
      .endAt(endAt != null ? new Date(endAt) : null)
      .withSchedule(schedule)
      .build();
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:18,代码来源:AbstractTest.java


示例10: scheduleRepeatingPeriodJob

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
private void scheduleRepeatingPeriodJob(RepeatingPeriodSchedulableJob job, boolean update) {
    logObjectIfNotNull(job);

    validateRepeatingPeriodSchedulableJob(job);

    MotechEvent motechEvent = job.getMotechEvent();

    JobId jobId = new RepeatingPeriodJobId(motechEvent);
    JobDetail jobDetail = newJob(MotechScheduledJob.class)
            .withIdentity(jobKey(jobId.value(), JOB_GROUP_NAME))
            .build();

    putMotechEventDataToJobDataMap(jobDetail.getJobDataMap(), motechEvent);

    jobDetail.getJobDataMap().put(EVENT_METADATA, createMetadataForMisfireSchedulableJob(job, motechEvent));

    ScheduleBuilder scheduleBuilder = PeriodIntervalScheduleBuilder.periodIntervalSchedule()
            .withRepeatPeriod(job.getRepeatPeriod())
            .withMisfireHandlingInstructionFireAndProceed();

    Trigger trigger = buildJobDetail(job, DateUtil.toDate(job.getStartDate()),
            DateUtil.toDate(job.getEndDate()), jobId, jobDetail, scheduleBuilder);
    scheduleJob(jobDetail, trigger, update);
}
 
开发者ID:motech,项目名称:motech,代码行数:25,代码来源:MotechSchedulerServiceImpl.java


示例11: getScheduleBuilder

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
/**
 * Get a {@link ScheduleBuilder} that is configured to produce a
 * schedule identical to this trigger's schedule.
 *
 * @see #getTriggerBuilder()
 */
@Override
public ScheduleBuilder<PeriodIntervalTrigger> getScheduleBuilder() {

    PeriodIntervalScheduleBuilder sb = PeriodIntervalScheduleBuilder.periodIntervalSchedule()
            .withRepeatPeriod(repeatPeriod)
            .withMisfireHandlingInstructionDoNothing();


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

    return sb;
}
 
开发者ID:motech,项目名称:motech,代码行数:26,代码来源:PeriodIntervalTriggerImpl.java


示例12: scheduleRepeatingJob

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
@Override
public void scheduleRepeatingJob(long interval) {
    Date jobStartTime = DateUtil.nowUTC().toDate();

    if (interval == 0) {
        throw new IllegalArgumentException("Invalid RepeatingSchedulableJob. The job repeat interval can not be 0");
    }

    JobDetail jobDetail = newJob(MdsScheduledJob.class)
            .withIdentity(jobKey(EMPTY_TRASH_JOB, JOB_GROUP_NAME))
            .build();

    ScheduleBuilder scheduleBuilder = simpleSchedule()
            .withIntervalInMilliseconds(interval)
            .withRepeatCount(MAX_REPEAT_COUNT);

    Trigger trigger = buildJobDetail(jobStartTime, jobDetail, scheduleBuilder);
    scheduleJob(jobDetail, trigger);
}
 
开发者ID:motech,项目名称:motech,代码行数:20,代码来源:MdsSchedulerServiceImpl.java


示例13: schedule

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
private static Scheduled schedule( Runnable runnable, ScheduleBuilder<?> scheduleBuilder ) {
    try {
        String identity = identity( runnable );

        JobDetail job = newJob( RunnableJob.class )
            .withIdentity( identity + "/job" )
            .storeDurably()
            .build();

        Trigger trigger = newTrigger()
            .withIdentity( identity + "/trigger" )
            .withSchedule( scheduleBuilder )
            .build();

        jobFactory.register( job, runnable );

        scheduler.scheduleJob( job, trigger );
        log.trace( "scheduling job {} with trigger {}", job, trigger );
        return new QuartzScheduled( job );
    } catch( org.quartz.SchedulerException e ) {
        throw new SchedulerException( e );
    }
}
 
开发者ID:oaplatform,项目名称:oap,代码行数:24,代码来源:Scheduler.java


示例14: createScheduleBuilder

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
private ScheduleBuilder<? extends Trigger> createScheduleBuilder() {
    if (StringUtils.startsWithIgnoreCase(schedulerExpr, "Every")) {
        return parseEveryExpr(schedulerExpr.substring("Every".length()));
    } else if (StringUtils.startsWithIgnoreCase(schedulerExpr, "At")) {
        return parseAtExpr(schedulerExpr.substring("At".length()));
    } else {
        return parseCron(schedulerExpr);
    }
}
 
开发者ID:bingoohuang,项目名称:westcache,代码行数:10,代码来源:ScheduledParser.java


示例15: getScheduleBuilder

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
@Override
@JsonIgnore
public ScheduleBuilder getScheduleBuilder() {
    return new ScheduleBuilder<SimpleTrigger>() {
        @Override
        protected MutableTrigger build() {
            return SimpleScheduleBuilder.simpleSchedule()
                    .withRepeatCount(repeatCount)
                    .withIntervalInMilliseconds(repeatInterval)
                    .withMisfireHandlingInstructionNextWithRemainingCount()
                    .build();
        }
    };
}
 
开发者ID:Netflix,项目名称:Fenzo,代码行数:15,代码来源:IntervalTrigger.java


示例16: buildAndComputeTrigger

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
protected OperableTrigger buildAndComputeTrigger(String triggerName,
    String triggerGroup,
    JobDetail job,
    Long startAt,
    Long endAt,
    ScheduleBuilder scheduleBuilder) {

  OperableTrigger trigger = buildTrigger(triggerName, triggerGroup, job, startAt, endAt, scheduleBuilder);
  trigger.computeFirstFireTime(null);
  return trigger;
}
 
开发者ID:FlavioF,项目名称:quartz-scheduler-hazelcast-jobstore,代码行数:12,代码来源:AbstractTest.java


示例17: buildJobDetail

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
private Trigger buildJobDetail(SchedulableJob schedulableJob, Date jobStartTime, Date jobEndTime,
                               JobId jobId, JobDetail jobDetail, ScheduleBuilder scheduleBuilder) {
    Trigger trigger = newTrigger()
            .withIdentity(triggerKey(jobId.value(), JOB_GROUP_NAME))
            .forJob(jobDetail)
            .withSchedule(scheduleBuilder)
            .startAt(jobStartTime)
            .endAt(jobEndTime)
            .build();
    DateTime now = now();

    if (schedulableJob.isIgnorePastFiresAtStart() && newDateTime(jobStartTime).isBefore(now)) {

        List<Date> pastTriggers = TriggerUtils.computeFireTimesBetween((OperableTrigger) trigger, null, jobStartTime, now.toDate());

        if (pastTriggers.size() > 0) {
            if (scheduleBuilder instanceof SimpleScheduleBuilder && ((RepeatingSchedulableJob) schedulableJob).getRepeatCount() != null) {
                ((SimpleScheduleBuilder) scheduleBuilder)
                        .withRepeatCount(((RepeatingSchedulableJob) schedulableJob).getRepeatCount() - pastTriggers.size());
            }
            Date newStartTime = getFirstTriggerInFuture(trigger, now);
            trigger = newTrigger()
                    .withIdentity(triggerKey(jobId.value(), JOB_GROUP_NAME))
                    .forJob(jobDetail)
                    .withSchedule(scheduleBuilder)
                    .startAt(newStartTime)
                    .endAt(jobEndTime)
                    .build();
        }
    }
    return trigger;
}
 
开发者ID:motech,项目名称:motech,代码行数:33,代码来源:MotechSchedulerServiceImpl.java


示例18: getTriggerPropertyBundle

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
@Override
protected TriggerPropertyBundle getTriggerPropertyBundle(SimplePropertiesTriggerProperties properties) {
    Period repeatPeriod = Period.parse(properties.getString1());

    ScheduleBuilder<?> sb = PeriodIntervalScheduleBuilder.periodIntervalSchedule()
            .withRepeatPeriod(repeatPeriod);

    int timesTriggered = properties.getInt1();

    String[] statePropertyNames = {"timesTriggered"};
    Object[] statePropertyValues = {timesTriggered};

    return new TriggerPropertyBundle(sb, statePropertyNames, statePropertyValues);
}
 
开发者ID:motech,项目名称:motech,代码行数:15,代码来源:PeriodIntervalTriggerPersistenceDelegate.java


示例19: buildJobDetail

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
private Trigger buildJobDetail(Date jobStartTime, JobDetail jobDetail, ScheduleBuilder scheduleBuilder) {
    return newTrigger()
            .withIdentity(triggerKey(EMPTY_TRASH_JOB, JOB_GROUP_NAME))
            .forJob(jobDetail)
            .withSchedule(scheduleBuilder)
            .startAt(jobStartTime)
            .build();
}
 
开发者ID:motech,项目名称:motech,代码行数:9,代码来源:MdsSchedulerServiceImpl.java


示例20: parseAtExpr

import org.quartz.ScheduleBuilder; //导入依赖的package包/类
private static ScheduleBuilder<? extends Trigger> parseAtExpr(String atExpr) {
    Matcher matcher = atExprPattern.matcher(atExpr);
    if (!matcher.matches()) throw new RuntimeException(atExpr + " is not valid");

    if (matcher.group(1).equals("??")) {
        return CronScheduleBuilder.cronSchedule("0 " + matcher.group(2) + " * * * ?");
    }

    DateTimeFormatter formatter = DateTimeFormat.forPattern("HH:mm");
    DateTime dateTime = formatter.parseDateTime(matcher.group().trim());

    return CronScheduleBuilder.dailyAtHourAndMinute(dateTime.getHourOfDay(),
            dateTime.getMinuteOfHour());
}
 
开发者ID:bingoohuang,项目名称:quartz-glass,代码行数:15,代码来源:GlassSchedulerParser.java



注:本文中的org.quartz.ScheduleBuilder类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java CharacterOffsetBeginAnnotation类代码示例发布时间:2022-05-22
下一篇:
Java AsymmetricRelationship类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap