本文整理汇总了Java中org.quartz.TriggerBuilder.newTrigger方法的典型用法代码示例。如果您正苦于以下问题:Java TriggerBuilder.newTrigger方法的具体用法?Java TriggerBuilder.newTrigger怎么用?Java TriggerBuilder.newTrigger使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.TriggerBuilder
的用法示例。
在下文中一共展示了TriggerBuilder.newTrigger方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: createTrigger
import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
private Trigger createTrigger(final AnnotatedQuartzJob annotatedJob,
final JobDetail jobDetail) {
final QuartzScheduledJob annotation = annotatedJob.getAnnotation();
final Class<? extends Job> jobClass = annotatedJob.getJobClass();
final TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();
final String cronExpression = resolveCronExpression(annotation);
final boolean cronEnabled = cronExpression != null;
final boolean fixedRateEnabled = annotation.fixedRate() > 0;
if (cronEnabled == fixedRateEnabled) {
throw new IllegalStateException("Exactly one of 'cronExpression', 'fixedRate' is required. Offending class "
+ jobClass.getName());
}
if (cronEnabled) {
triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(cronExpression)
.inTimeZone(Constants.DEFAULT_TIMEZONE.toTimeZone()));
} else {
triggerBuilder.withSchedule(SimpleScheduleBuilder.simpleSchedule()
.withIntervalInMilliseconds(annotation.fixedRate())
.repeatForever());
}
return triggerBuilder.forJob(jobDetail)
.startNow()
.withIdentity(jobDetail.getKey().getName() + "_trigger", jobDetail.getKey().getGroup() + "_triggers")
.build();
}
示例3: 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();
}
示例4: addScript
import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
private void addScript(ScheduledScript script) throws Exception {
TriggerBuilder triggerBuilder = TriggerBuilder.newTrigger();
triggerBuilder.withIdentity(script.getId());
if (script.getCron() != null) {
triggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(script.getCron()));
}
if (script.getAt() != null) {
triggerBuilder.startAt(script.getAt());
}
if (script.getUntil() != null) {
triggerBuilder.endAt(script.getUntil());
}
Trigger trigger = triggerBuilder.build();
JobDataMap dataMap = new JobDataMap();
dataMap.put(SCRIPT_DATAMAP_KEY, script);
dataMap.put(SCRIPT_MANAGER_DATAMAP_KEY, scriptManager);
JobBuilder jobBuilder = JobBuilder.newJob();
jobBuilder.withIdentity(script.getId());
jobBuilder.ofType(ScriptJob.class);
jobBuilder.setJobData(dataMap);
scheduler.scheduleJob(jobBuilder.build(), trigger);
}
示例5: addTrigger
import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
public JSONResult addTrigger(String schedulerName, String jobName, String jobGroup,
String triggerName, String triggerGroup, String cronExpression, String description,
String priority, Date startDate, Date endDate, Map<String, Object> dataMap) {
try {
Assert.notEmpty(schedulerName, "schedulerName can not be empty");
Assert.notEmpty(jobName, "jobName can not be empty");
Assert.notEmpty(jobGroup, "jobGroup can not be empty");
Assert.notEmpty(triggerName, "triggerName can not be empty");
Assert.notEmpty(triggerGroup, "triggerGroup can not be empty");
Assert.isCronExpression(cronExpression, "cronExpression is error");
TriggerBuilder<Trigger> triggerTriggerBuilder = TriggerBuilder.newTrigger();
triggerTriggerBuilder = triggerTriggerBuilder.withIdentity(triggerName, triggerGroup);
if (!StringUtils.isEmpty(description)) {
triggerTriggerBuilder = triggerTriggerBuilder.withDescription(description);
}
if (!StringUtils.isEmpty(priority) && StringUtils.isInteger(priority)) {
Assert.isInteger(priority, "priority must be int");
triggerTriggerBuilder.withPriority(Integer.parseInt(priority));
}
if (startDate != null) {
triggerTriggerBuilder.startAt(startDate);
}
if (endDate != null) {
triggerTriggerBuilder.endAt(endDate);
}
//jobDataMap
if (dataMap != null && dataMap.size() > 0) {
JobDataMap jobDataMap = new JobDataMap();
for (Map.Entry<String, Object> dataKey : dataMap.entrySet()) {
if (!StringUtils.isEmpty(dataKey.getKey())) {
jobDataMap.put(dataKey.getKey(), dataKey.getValue());
}
}
triggerTriggerBuilder.usingJobData(jobDataMap);
}
triggerTriggerBuilder.forJob(jobName, jobGroup);
CronTrigger trigger = triggerTriggerBuilder.withSchedule(CronScheduleBuilder.cronSchedule(cronExpression))
.build();
//JobDetail jobDetail = QuartzWebManager.getJob(schedulerName, jobName, jobGroup);
// 存在更新不存在,添加
if (!QuartzWebManager.checkTriggerExists(schedulerName, triggerName, triggerGroup)) {
QuartzWebManager.addTriggerForJob(schedulerName, trigger);
} else {
QuartzWebManager.updateTriggerForJob(schedulerName, trigger);
}
return JSONResult.build(JSONResult.RESULT_CODE_SUCCESS, "ok");
} catch (Exception e) {
e.printStackTrace();
return JSONResult.build(JSONResult.RESULT_CODE_ERROR, e.getMessage());
}
}
示例6: configureTriggerJob
import org.quartz.TriggerBuilder; //导入方法依赖的package包/类
private Trigger configureTriggerJob(String jobName, String jobGroup, Job job) {
TriggerBuilder<Trigger> triggerBuilder = TriggerBuilder.newTrigger();
// base trigger configuration
triggerBuilder.withIdentity(jobName, jobGroup);
if (job.getStartTime() != null)
triggerBuilder.startAt(job.getStartTime());
else {
if (job.getActive())
triggerBuilder.startNow();
}
if (job.getEndTime() != null)
triggerBuilder.endAt(job.getEndTime());
triggerBuilder.withPriority(job.getJobTriggerPriority());
// propietary trigger configuration
if (job.getJobTriggerType().getCode().equals(Job.JOB_TRIGGER_TYPE.SIMPLE.name())) {
SimpleScheduleBuilder simpleScheduleBuilder = SimpleScheduleBuilder.simpleSchedule();
if (job.getJobInterval() != null) {
if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.SECOND.name()))
simpleScheduleBuilder.withIntervalInSeconds(job.getJobInterval());
else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.MINUTE.name()))
simpleScheduleBuilder.withIntervalInMinutes(job.getJobInterval());
else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.HOUR.name()))
simpleScheduleBuilder.withIntervalInHours(job.getJobInterval());
else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.DAY.name()))
simpleScheduleBuilder.withIntervalInHours(job.getJobInterval() * 24);
else if (job.getJobIntervalType().getCode().equals(Job.JOB_INTERVAL_TYPE.WEEK.name()))
simpleScheduleBuilder.withIntervalInHours(job.getJobInterval() * 24 * 7);
}
if (job.getRepeatCount() != null)
simpleScheduleBuilder.withRepeatCount(job.getRepeatCount());
else
simpleScheduleBuilder.repeatForever();
triggerBuilder.withSchedule(simpleScheduleBuilder);
}
else if (job.getJobTriggerType().getCode().equals(Job.JOB_TRIGGER_TYPE.CRON.name())) {
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
triggerBuilder.withSchedule(cronScheduleBuilder);
}
return triggerBuilder.build();
}