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