本文整理汇总了Java中org.quartz.TriggerBuilder.usingJobData方法的典型用法代码示例。如果您正苦于以下问题:Java TriggerBuilder.usingJobData方法的具体用法?Java TriggerBuilder.usingJobData怎么用?Java TriggerBuilder.usingJobData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.TriggerBuilder
的用法示例。
在下文中一共展示了TriggerBuilder.usingJobData方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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());
}
}