本文整理匯總了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());
}
}