本文整理了Java中org.quartz.Scheduler.addJob()
方法的一些代码示例,展示了Scheduler.addJob()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scheduler.addJob()
方法的具体详情如下:
包路径:org.quartz.Scheduler
类名称:Scheduler
方法名:addJob
[英]Add the given Job
to the Scheduler - with no associated Trigger
. The Job
will be 'dormant' until it is scheduled with a Trigger
, or Scheduler.triggerJob()
is called for it.
The Job
must by definition be 'durable', if it is not, SchedulerException will be thrown.
[中]将给定的Job
添加到计划程序中-没有关联的Trigger
。Job
将处于“休眠”状态,直到使用Trigger
或Scheduler.triggerJob()
调用它。
根据定义,Job
必须是“持久的”,否则将抛出ScheduleException。
代码示例来源:origin: spring-projects/spring-framework
/**
* Add the given job to the Scheduler, if it doesn't already exist.
* Overwrites the job in any case if "overwriteExistingJobs" is set.
* @param jobDetail the job to add
* @return {@code true} if the job was actually added,
* {@code false} if it already existed before
* @see #setOverwriteExistingJobs
*/
private boolean addJobToScheduler(JobDetail jobDetail) throws SchedulerException {
if (this.overwriteExistingJobs || getScheduler().getJobDetail(jobDetail.getKey()) == null) {
getScheduler().addJob(jobDetail, true);
return true;
}
else {
return false;
}
}
代码示例来源:origin: org.springframework/spring-context-support
/**
* Add the given job to the Scheduler, if it doesn't already exist.
* Overwrites the job in any case if "overwriteExistingJobs" is set.
* @param jobDetail the job to add
* @return {@code true} if the job was actually added,
* {@code false} if it already existed before
* @see #setOverwriteExistingJobs
*/
private boolean addJobToScheduler(JobDetail jobDetail) throws SchedulerException {
if (this.overwriteExistingJobs || getScheduler().getJobDetail(jobDetail.getKey()) == null) {
getScheduler().addJob(jobDetail, true);
return true;
}
else {
return false;
}
}
代码示例来源:origin: kiegroup/jbpm
} else {
scheduler.addJob(jobq, true, true);
scheduler.rescheduleJob(triggerq.getKey(), triggerq);
代码示例来源:origin: quartz-scheduler/quartz
sched.addJob(detail, true, true); // add the job regardless is durable or not b/c we have trigger to add
else
sched.addJob(detail, true, false); // add the job only if a replacement or durable, else exception will throw!
代码示例来源:origin: quartz-scheduler/quartz
sched.addJob(detail, true, true); // add the job regardless is durable or not b/c we have trigger to add
else
sched.addJob(detail, true, false); // add the job only if a replacement or durable, else exception will throw!
代码示例来源:origin: net.sf.ehcache/ehcache
private void scheduleOverseerJob() throws SchedulerException {
JobDetail seed = makeOverseerJob();
// build our trigger
CronScheduleBuilder cronSchedule = CronScheduleBuilder.cronSchedule(config.getCronExpression());
CronTrigger trigger = TriggerBuilder.newTrigger()
.withIdentity(OVERSEER_JOB_NAME, groupName)
.forJob(seed).withSchedule(cronSchedule)
.build();
try {
scheduler.addJob(seed, false);
} catch (SchedulerException e) {
// job already present
}
try {
scheduler.scheduleJob(trigger);
} catch (SchedulerException e) {
// trigger already present
try {
scheduler.rescheduleJob(trigger.getKey(), trigger);
} catch (SchedulerException ee) {
LOG.error("Unable to modify trigger for: " + trigger.getKey());
}
}
}
代码示例来源:origin: myschedule/myschedule-quartz-extra
public void addJob(JobDetail job, boolean replace, boolean storeNonDurableWhileAwaitingScheduling) {
try {
scheduler.addJob(job, replace, storeNonDurableWhileAwaitingScheduling);
} catch (SchedulerException e) {
throw new QuartzRuntimeException(e);
}
}
代码示例来源:origin: com.blazebit/blaze-quartz-utils
public static void add(Scheduler sched, Class<? extends Job> clazz,
String jobName, String jobGroup,
Map<String, ? extends Object> dataMap) throws SchedulerException {
sched.addJob(create(clazz, jobName, jobGroup, dataMap, true), false);
}
代码示例来源:origin: myschedule/myschedule-quartz-extra
public void addJob(JobDetail job, boolean replace) {
try {
scheduler.addJob(job, replace);
} catch (SchedulerException e) {
throw new QuartzRuntimeException(e);
}
}
代码示例来源:origin: org.codelibs/elasticsearch-quartz
public void addJob(final JobDetail jobDetail, final boolean replace) {
try {
scheduler.addJob(jobDetail, replace);
} catch (final SchedulerException e) {
throw new QuartzSchedulerException(e);
}
}
代码示例来源:origin: org.kuali.kfs/kfs-core
protected void updateStatus(String groupName, String jobName, String jobStatus) {
try {
JobDetail jobDetail = scheduler.getJobDetail(jobName, groupName);
updateStatus(jobDetail, jobStatus);
scheduler.addJob(jobDetail, true);
}
catch (SchedulerException e) {
throw new RuntimeException(new StringBuffer("Caught scheduler exception while updating job status: ").append(jobName).append(", ").append(jobStatus).toString(), e);
}
}
代码示例来源:origin: org.kuali.kfs/kfs-core
protected void addJob(JobDetail jobDetail) {
try {
if ( LOG.isInfoEnabled() ) {
LOG.info("Adding job: " + jobDetail.getFullName());
}
scheduler.addJob(jobDetail, true);
}
catch (SchedulerException e) {
throw new RuntimeException("Caught exception while adding job: " + jobDetail.getFullName(), e);
}
}
代码示例来源:origin: OpenNMS/opennms
/**
* <p>afterPropertiesSet</p>
*
* @throws java.lang.Exception if any.
*/
@Override
public void afterPropertiesSet() throws Exception {
LOG.debug("Adding job {} to scheduler", m_jobDetail.getKey().getName());
m_scheduler.addJob(m_jobDetail, true);
}
代码示例来源:origin: org.kuali.kfs/kfs-core
public void addScheduled(JobDetail job) {
try {
job.setGroup(SCHEDULED_GROUP);
scheduler.addJob(job, true);
}
catch (SchedulerException ex) {
throw new RuntimeException("Unable to add job to scheduled group: " + job.getName(), ex);
}
}
代码示例来源:origin: org.kuali.kfs/kfs-core
public void addUnscheduled(JobDetail job) {
try {
job.setGroup(UNSCHEDULED_GROUP);
scheduler.addJob(job, true);
}
catch (SchedulerException ex) {
throw new RuntimeException("Unable to add job to unscheduled group: " + job.getName(), ex);
}
}
代码示例来源:origin: com.threewks.thundr/thundr-contrib-quartz
@Override
public void addJob(JobDetail jobDetail, boolean replace) throws QuartzException {
try {
delegate.addJob(jobDetail, replace);
} catch (SchedulerException e) {
Logger.error(e.getMessage());
throw new QuartzException(e);
}
}
代码示例来源:origin: com.threewks.thundr/thundr-quartz
@Override
public void addJob(JobDetail jobDetail, boolean replace) throws QuartzException {
try {
delegate.addJob(jobDetail, replace);
} catch (SchedulerException e) {
Logger.error(e.getMessage());
throw new QuartzException(e);
}
}
代码示例来源:origin: myschedule/myschedule-quartz-extra
/**
* Update existing job with newJobDetail and return the old one.
*/
public JobDetail updateJobDetail(JobDetail newJobDetail) {
try {
JobDetail oldJob = scheduler.getJobDetail(newJobDetail.getKey());
scheduler.addJob(newJobDetail, true);
return oldJob;
} catch (SchedulerException e) {
throw new QuartzRuntimeException(e);
}
}
代码示例来源:origin: com.ksc.mission.base/scheduler
public void update(IMessage jobMessage, String schedule) throws SchedulerException {
JobDetail job = jobFor(jobMessage);
scheduler.addJob(job, true, true);
Trigger oldTrigger = scheduler.getTrigger(triggerKeyFor(jobMessage));
scheduler.rescheduleJob(oldTrigger.getKey(), triggerFor(schedule, jobMessage));
}
代码示例来源:origin: com.nesscomputing.components/ness-quartz
@Before
public void setUp() throws Exception
{
config = Config.getConfig(URI.create("classpath:/test-config"), "builder");
nessJobConfig = config.getConfiguration("ness.job");
scheduler = createMock(Scheduler.class);
EasyMock.expect(scheduler.scheduleJob(EasyMock.capture(jobDetailCapture), EasyMock.capture(triggerCapture))).andReturn(null).anyTimes();
scheduler.addJob(EasyMock.capture(jobAddCapture), EasyMock.anyBoolean());
EasyMock.expectLastCall().anyTimes();
replayAll();
}
内容来源于网络,如有侵权,请联系作者删除!