本文整理汇总了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();
}
示例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();
}
示例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;
}
示例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);
}
示例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();
}
示例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();
}
示例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"));
}
示例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"));
}
示例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 * ?"));
}
示例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 * ?"));
}
示例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 * ?"));
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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();
}