本文整理汇总了Java中org.quartz.Scheduler.addJob方法的典型用法代码示例。如果您正苦于以下问题:Java Scheduler.addJob方法的具体用法?Java Scheduler.addJob怎么用?Java Scheduler.addJob使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.quartz.Scheduler
的用法示例。
在下文中一共展示了Scheduler.addJob方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
public static void addJob(JobDetail jobDetail,
boolean replace,Scheduler scheduler) throws SchedulerException {
scheduler.addJob(jobDetail, replace);
}
示例2: addJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
@Transactional
@Override
public boolean addJob(ScheduleJobEntity job) {
try {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
JobDetail jobDetail = job.getJobDetail();
if(StringUtils.isEmpty(job.getTriggerGroup()))
{
//使用默认组名称:DEFAULT
job.setTriggerGroup(Scheduler.DEFAULT_GROUP);
}
// 存储job
jobDetail.getJobDataMap().put("scheduleJob", job);
if(!StringUtils.isEmpty(job.getTriggerName())){
// 表达式调度构建器
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder
.cronSchedule(job.getCronExpression());
// 按新的cronExpression表达式构建一个新的trigger
CronTrigger trigger = newTrigger()
.withIdentity(job.getTriggerName(),job.getTriggerGroup())
.startAt(job.getStartDate()) // job开始日期
.endAt(job.getEndDate())// job结束日期
.withSchedule(scheduleBuilder).build();
// 将job添加到quartz的scheduler容器
scheduler.scheduleJob(jobDetail, trigger);
}else
{
scheduler.addJob(jobDetail, true);
}
return Boolean.TRUE;
} catch (SchedulerException e) {
throw new ServiceException(e);
}
}
示例3: addJob
import org.quartz.Scheduler; //导入方法依赖的package包/类
/**
* 添加job
*
* @param schedulerName
* @param jobDetail
* @return
* @throws SchedulerException
*/
public void addJob(String schedulerName, JobDetail jobDetail, boolean replace) throws SchedulerException {
Assert.notEmpty(schedulerName, "schedulerName can not be empty");
Assert.notNull(jobDetail, "jobDetail can not be null");
Scheduler scheduler = this.getAssertScheduler(schedulerName);
scheduler.addJob(jobDetail, replace);
}