當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。