当前位置: 首页>>代码示例>>Java>>正文


Java TriggerBuilder.build方法代码示例

本文整理汇总了Java中org.quartz.TriggerBuilder.build方法的典型用法代码示例。如果您正苦于以下问题:Java TriggerBuilder.build方法的具体用法?Java TriggerBuilder.build怎么用?Java TriggerBuilder.build使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.quartz.TriggerBuilder的用法示例。


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

示例1: buildTrigger

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
@SuppressWarnings({ "unchecked", "rawtypes" })
private Trigger buildTrigger(String confId, JobScheduling conf, JobKey job) {

    TriggerKey key = this.buildTiggerKey(confId);
    TriggerBuilder trigger = TriggerBuilder.newTrigger().withIdentity(key);

    // Set CRON value
    if (StringUtils.isNotEmpty(conf.getValue())) {
        trigger.withSchedule(CronScheduleBuilder.cronSchedule(conf.getValue()));
    }

    // Set DATE value
    if (conf.getStartAt() > 0) {
        trigger.startAt(new Date(conf.getStartAt()));
    }

    if (job != null) {
        trigger.forJob(job);
    }

    return trigger.build();
}
 
开发者ID:AirVantage,项目名称:av-sched,代码行数:23,代码来源:JobSchedulingServiceImpl.java

示例2: getTrigger

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
@Override
public Trigger getTrigger() {
	Checker.require(triggerKey).notNull();
	TriggerBuilder<Trigger> triggerBuilder = newTrigger().withIdentity(triggerKey);
	if (getStartTime() == null) {
		triggerBuilder.startNow();
	} else {
		triggerBuilder.startAt(getStartTime());
	}
	if (getEndTime() != null) {
		triggerBuilder.endAt(getEndTime());
	}
	if (isRepeatable()) {
		SimpleScheduleBuilder scheduleBuilder = simpleSchedule();
		scheduleBuilder.withIntervalInSeconds(getIntervalInSeconds());
		if (isRepeatForever()) {
			scheduleBuilder.repeatForever();
		} else {
			scheduleBuilder.withRepeatCount(getRepeatCount());
		}
		triggerBuilder.withSchedule(scheduleBuilder);
	}
	return triggerBuilder.build();
}
 
开发者ID:daileyet,项目名称:webscheduler,代码行数:25,代码来源:SimpleTaskTrigger.java

示例3: createCronTrigger

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
/**
 * 创建复杂触发器
 * @param jobName 作业名
 * @param groupName 组名
 * @param cronExpression cron表达式
 * @param startTime 开始时间
 * @param endTime 结束时间
 * @return
 */
public static Trigger createCronTrigger(ExecutionContext executionContext, String cronExpression,Date startTime,Date endTime) {
	
	TriggerBuilder<CronTrigger> triggerBuilder=newTrigger()
	         .withIdentity(GuidUtil.CreateGuid(), executionContext.getProcessDefinition().getId())
	         .withSchedule(cronSchedule(cronExpression));
	
	if(startTime!=null){
		triggerBuilder.startAt(startTime);
	}
	if(endTime!=null){
		triggerBuilder.endAt(endTime);
	}
	
	 CronTrigger trigger = triggerBuilder
        .build();
	return trigger;
}
 
开发者ID:fixteam,项目名称:fixflow,代码行数:27,代码来源:QuartzUtil.java

示例4: createMember

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
@Override
public void createMember(RequestContext ctx, ResourceState state, Responder responder) throws Exception {

    String id = UUID.randomUUID().toString();

    TriggerBuilder triggerBuilder = TriggerBuilder.newTrigger();
    triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule((String) state.getProperty("cron")));
    triggerBuilder.withIdentity(id);
    Trigger trigger = triggerBuilder.build();

    TriggerResource resource = new TriggerResource(this, trigger);

    JobDataMap dataMap = new JobDataMap();
    dataMap.put("resource", resource);

    JobBuilder jobBuilder = JobBuilder.newJob();
    jobBuilder.withIdentity(id);
    jobBuilder.ofType(LiveOakJob.class);
    jobBuilder.setJobData(dataMap);

    JobDetail jobDetail = jobBuilder.build();

    this.scheduler.scheduleJob(jobDetail, trigger);
    this.children.put(id, resource);
    responder.resourceCreated(resource);
}
 
开发者ID:liveoak-io,项目名称:liveoak,代码行数:27,代码来源:SchedulerResource.java

示例5: getTrigger

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
public Trigger getTrigger(Trigger trigger) throws ParseException {
    fixParameters();

    TriggerBuilder<Trigger> builder = TriggerBuilder.newTrigger().forJob(trigger.getJobKey().getName(), trigger.getJobKey().getGroup())
            .withIdentity(trigger.getKey().getName(), trigger.getKey().getGroup())
            .startAt(startTime).endAt(endTime)
            .usingJobData(JobDataMapUtils.fromDataMapStr(dataMap));

    if (repeatCount == -1) {
        builder.withSchedule(SimpleScheduleBuilder.simpleSchedule().repeatForever()
                .withIntervalInMilliseconds(intervalInMilliseconds));
    } else {
        builder.withSchedule(SimpleScheduleBuilder.simpleSchedule().withRepeatCount(repeatCount)
                .withIntervalInMilliseconds(intervalInMilliseconds));
    }

    return builder.build();
}
 
开发者ID:bingoohuang,项目名称:quartz-glass,代码行数:19,代码来源:SimpleTriggerForm.java

示例6: getTrigger

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
public Trigger getTrigger() throws ParseException {
    fixParameters();

    TriggerBuilder<Trigger> builder = TriggerBuilder.newTrigger().forJob(name.trim(), group.trim()).withIdentity(triggerName.trim(), triggerGroup.trim())
            .startAt(startTime).endAt(endTime)
            .usingJobData(JobDataMapUtils.fromDataMapStr(dataMap));

    if (repeatCount == -1) {
        builder.withSchedule(SimpleScheduleBuilder.simpleSchedule().repeatForever()
                .withIntervalInMilliseconds(intervalInMilliseconds));
    } else {
        builder.withSchedule(SimpleScheduleBuilder.simpleSchedule().withRepeatCount(repeatCount)
                .withIntervalInMilliseconds(intervalInMilliseconds));
    }

    return builder.build();
}
 
开发者ID:bingoohuang,项目名称:quartz-glass,代码行数:18,代码来源:NewSimpleTriggerForm.java

示例7: weekly1

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
@Test
public void weekly1() {
  Weekly weekly = scheduleFactory.weekly(new Date(), Sets.newSet(Weekday.SAT));
  TriggerBuilder triggerBuilder = underTest.convert(weekly);
  Trigger trigger = triggerBuilder.build();

  assertThat(trigger, instanceOf(CronTrigger.class));
  String cronExpression = ((CronTrigger) trigger).getCronExpression();
  assertThat(cronExpression, equalTo(cronTimeParts(weekly.getStartAt()) + " ? * SAT"));
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:11,代码来源:QuartzTriggerConverterTest.java

示例8: weekly2

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
@Test
public void weekly2() {
  Weekly weekly = scheduleFactory.weekly(new Date(), Sets.newSet(Weekday.SAT, Weekday.FRI));
  TriggerBuilder triggerBuilder = underTest.convert(weekly);
  Trigger trigger = triggerBuilder.build();

  assertThat(trigger, instanceOf(CronTrigger.class));
  String cronExpression = ((CronTrigger) trigger).getCronExpression();
  assertThat(cronExpression, equalTo(cronTimeParts(weekly.getStartAt()) + " ? * FRI,SAT"));
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:11,代码来源:QuartzTriggerConverterTest.java

示例9: monthly1

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
@Test
public void monthly1() {
  Monthly monthly = scheduleFactory.monthly(new Date(), CalendarDay.days(2));
  TriggerBuilder triggerBuilder = underTest.convert(monthly);
  Trigger trigger = triggerBuilder.build();

  assertThat(trigger, instanceOf(CronTrigger.class));
  String cronExpression = ((CronTrigger) trigger).getCronExpression();
  assertThat(cronExpression, equalTo(cronTimeParts(monthly.getStartAt()) + " 2 * ?"));
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:11,代码来源:QuartzTriggerConverterTest.java

示例10: monthly2

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
@Test
public void monthly2() {
  Monthly monthly = scheduleFactory.monthly(new Date(), CalendarDay.days(1, 2, 3, 10, 11, 12));
  TriggerBuilder triggerBuilder = underTest.convert(monthly);
  Trigger trigger = triggerBuilder.build();

  assertThat(trigger, instanceOf(CronTrigger.class));
  String cronExpression = ((CronTrigger) trigger).getCronExpression();
  assertThat(cronExpression, equalTo(
      cronTimeParts(monthly.getStartAt()) + " 1,2,3,10,11,12 * ?"));
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:12,代码来源:QuartzTriggerConverterTest.java

示例11: monthly3

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
@Test
public void monthly3() {
  Monthly monthly = scheduleFactory.monthly(new Date(), Sets.newSet(CalendarDay.lastDay()));
  TriggerBuilder triggerBuilder = underTest.convert(monthly);
  Trigger trigger = triggerBuilder.build();

  assertThat(trigger, instanceOf(CronTrigger.class));
  String cronExpression = ((CronTrigger) trigger).getCronExpression();
  assertThat(cronExpression, equalTo(cronTimeParts(monthly.getStartAt()) + " L * ?"));
}
 
开发者ID:sonatype,项目名称:nexus-public,代码行数:11,代码来源:QuartzTriggerConverterTest.java

示例12: scheduleJob

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
public String scheduleJob(JSONObject jsonObject) {
    try {
        TriggerBuilder triggerBuilder = buildTrigger(jsonObject);
        Trigger trigger = triggerBuilder.build();
        JobBuilder jobBuilder = buildJob(jsonObject);
        JobDetail jobDetail = jobBuilder.build(); //build a new jobDetail
        Date date;
        //if the job with that name.group doesn't exists, add the new builded job to the scheduler with the trigger
        if (!sched.checkExists(JobKey.jobKey(jobDetail.getKey().getName(), jobDetail.getKey().getGroup()))) {
            date = sched.scheduleJob(jobDetail, trigger);
        } else {
            //jobDetail = sched.getJobDetail(JobKey.jobKey(jobDetail.getKey().getName(), jobDetail.getKey().getGroup())); //set the jobDetail to the existing job
            date = sched.scheduleJob(trigger);
        }

        /*//if email data is defined, then create a new job listener, set the notificationEmail and add it to the scheduler
         if (jobDetail.getJobDataMap().containsKey("notificationEmail")) {
         //Adding a JobListener that is interested in a particular job (send email upon job finished)
         //Set the job listener name (jobName.jobGroup) to be able to remove it later
         SendEmailJobListener sml = new SendEmailJobListener(jobDetail.getKey().getName() + "." + jobDetail.getKey().getGroup(), jobDetail.getJobDataMap().getString("notificationEmail"));
         sched.getListenerManager().addJobListener(sml, KeyMatcher.keyEquals(jobDetail.getKey()));
         }
         //else, there is no job listener to remove, since this method creates a new job*/
        return date.toString();
    } catch (SchedulerException e) {
        e.printStackTrace();
        return e.getMessage();
    }
}
 
开发者ID:disit,项目名称:sce-backend,代码行数:30,代码来源:Main.java

示例13: rescheduleJob

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
public String rescheduleJob(JSONObject jsonObject, String oldTriggerName, String oldTriggerGroup) {
    try {
        //Map<String, String[]> m = new HashMap<>();
        //m.putAll(map);
        TriggerBuilder triggerBuilder = buildTrigger(jsonObject);
        Trigger trigger = triggerBuilder.build();
        Date date = sched.rescheduleJob(TriggerKey.triggerKey(oldTriggerName, oldTriggerGroup), trigger);
        return date.toString();
    } catch (SchedulerException e) {
        return e.getMessage();
    }
}
 
开发者ID:disit,项目名称:sce-backend,代码行数:13,代码来源:Main.java

示例14: createCronTrigger

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
/**
 * 创建复杂触发器
 * 
 * @param jobName
 *            作业名
 * @param groupName
 *            组名
 * @param cronExpression
 *            cron表达式
 * @param startTime
 *            开始时间
 * @param endTime
 *            结束时间
 * @return
 */
public final static Trigger createCronTrigger(ListenerExecutionContext executionContext,
    String cronExpression, Date startTime, Date endTime) {
	
	TriggerBuilder<CronTrigger> triggerBuilder = newTrigger().withIdentity(GuidUtil.CreateGuid(), executionContext.getProcessInstanceId()).withSchedule(cronSchedule(cronExpression));
	
	if (startTime != null) {
		triggerBuilder.startAt(startTime);
	}
	if (endTime != null) {
		triggerBuilder.endAt(endTime);
	}
	
	CronTrigger trigger = triggerBuilder.build();
	return trigger;
}
 
开发者ID:FoxBPM,项目名称:FoxBPM,代码行数:31,代码来源:QuartzUtil.java

示例15: createTrigger

import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
protected Trigger createTrigger(JobDataMap data, Date start, int interval,
		int repeat, Date end) {

	TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();

	if (data != null) {
		triggerBuilder.usingJobData(data);
	}
	if (interval > 0) {
		SimpleScheduleBuilder schedule = SimpleScheduleBuilder
				.simpleSchedule();
		schedule.withIntervalInMilliseconds(interval).withRepeatCount(
				repeat);
		triggerBuilder.withSchedule(schedule);
	}

	if (start != null) {
		triggerBuilder.startAt(start);
	} else {
		triggerBuilder.startNow();
	}

	if (end != null) {
		triggerBuilder.endAt(end);
	}

	return triggerBuilder.build();
}
 
开发者ID:ludup,项目名称:hypersocket-framework,代码行数:29,代码来源:SchedulerServiceImpl.java


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