本文整理了Java中org.quartz.Scheduler.rescheduleJob()
方法的一些代码示例,展示了Scheduler.rescheduleJob()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Scheduler.rescheduleJob()
方法的具体详情如下:
包路径:org.quartz.Scheduler
类名称:Scheduler
方法名:rescheduleJob
[英]Remove (delete) the org.quartz.Trigger
with the given name, and store the new given one - which must be associated with the same job (the new trigger must have the job name & group specified) - however, the new trigger need not have the same name as the old trigger.
[中]移除(删除)具有给定名称的org.quartz.Trigger
,并存储新的给定触发器-必须与同一作业关联(新触发器必须指定作业名称和组)-但是,新触发器不需要与旧触发器具有相同的名称。
代码示例来源:origin: stackoverflow.com
ServletContext ctx = request.getServletContext();
StdSchedulerFactory factory = (StdSchedulerFactory) ctx.getAttribute(QuartzListener.QUARTZ_FACTORY_KEY);
Scheduler scheduler = factory.getScheduler();
Trigger trigger = TriggerBuilder.newTrigger().withIdentity("simple").withSchedule(
CronScheduleBuilder.cronSchedule(newCronExpression)).startNow().build();
Date date = scheduler.rescheduleJob(new TriggerKey("simple"), trigger);
代码示例来源:origin: xuxueli/xxl-job
scheduler.rescheduleJob(triggerKey, oldTrigger);
代码示例来源:origin: spring-projects/spring-framework
getScheduler().rescheduleJob(trigger.getKey(), trigger);
getScheduler().rescheduleJob(trigger.getKey(), trigger);
代码示例来源:origin: elasticjob/elastic-job-lite
/**
* 重新调度作业.
*
* @param cron CRON表达式
*/
public synchronized void rescheduleJob(final String cron) {
try {
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(TriggerKey.triggerKey(triggerIdentity));
if (!scheduler.isShutdown() && null != trigger && !cron.equals(trigger.getCronExpression())) {
scheduler.rescheduleJob(TriggerKey.triggerKey(triggerIdentity), createTrigger(cron));
}
} catch (final SchedulerException ex) {
throw new JobSystemException(ex);
}
}
代码示例来源:origin: wuyouzhuguli/FEBS-Shiro
/**
* 更新定时任务
*/
public static void updateScheduleJob(Scheduler scheduler, Job scheduleJob) {
try {
TriggerKey triggerKey = getTriggerKey(scheduleJob.getJobId());
// 表达式调度构建器
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression())
.withMisfireHandlingInstructionDoNothing();
CronTrigger trigger = getCronTrigger(scheduler, scheduleJob.getJobId());
if (trigger == null) {
throw new SchedulerException("获取Cron表达式失败");
} else {
// 按新的cronExpression表达式重新构建trigger
trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
// 参数
trigger.getJobDataMap().put(Job.JOB_PARAM_KEY, scheduleJob);
}
scheduler.rescheduleJob(triggerKey, trigger);
// 暂停任务
if (scheduleJob.getStatus().equals(Job.ScheduleStatus.PAUSE.getValue())) {
pauseJob(scheduler, scheduleJob.getJobId());
}
} catch (SchedulerException e) {
log.error("更新定时任务失败", e);
}
}
代码示例来源:origin: org.springframework/spring-context-support
getScheduler().rescheduleJob(trigger.getKey(), trigger);
getScheduler().rescheduleJob(trigger.getKey(), trigger);
代码示例来源:origin: kiegroup/jbpm
scheduler.rescheduleJob(triggerq.getKey(), triggerq);
代码示例来源:origin: quartz-scheduler/quartz
sched.rescheduleJob(trigger.getKey(), trigger);
} else {
if (log.isDebugEnabled()) {
sched.rescheduleJob(trigger.getKey(), trigger);
sched.rescheduleJob(trigger.getKey(), trigger);
} else {
if (log.isDebugEnabled()) {
sched.rescheduleJob(trigger.getKey(), trigger);
代码示例来源:origin: quartz-scheduler/quartz
sched.rescheduleJob(trigger.getKey(), trigger);
} else {
if (log.isDebugEnabled()) {
sched.rescheduleJob(trigger.getKey(), trigger);
sched.rescheduleJob(trigger.getKey(), trigger);
} else {
if (log.isDebugEnabled()) {
sched.rescheduleJob(trigger.getKey(), trigger);
代码示例来源: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: bill1012/AdminEAP
/**
* 更新时间表达式
*/
public void rescheduleJob(ScheduleJob scheduleJob) throws SchedulerException {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
TriggerKey triggerKey = TriggerKey.triggerKey(scheduleJob.getJobName(), scheduleJob.getJobGroup());
// 获取trigger
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
// 表达式调度构建器
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression());
// 按新的cronExpression表达式重新构建trigger
trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
// 按照新的trigger重新设置job执行
scheduler.rescheduleJob(triggerKey, trigger);
}
代码示例来源:origin: bill1012/AdminEAP
public void scheduleCronJobs() throws SchedulerException {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
List<ScheduleJob> jobList = getAllJobs(null, null);
for (ScheduleJob job : jobList) {
TriggerKey triggerKey = TriggerKey.triggerKey(job.getJobName(), job.getJobGroup());
// 获取trigger,即在spring配置文件中定义的bean id="myTrigger"
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
// 不存在,创建一个
// if (null == trigger) {
if (!scheduler.checkExists(triggerKey)) {
JobDetail jobDetail = JobBuilder.newJob(QuartzJobFactory.class).withIdentity(job.getJobName(),
job.getJobGroup()).build();
// 表达式调度构建器
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
// 按新的cronExpression表达式构建一个新的trigger
trigger = TriggerBuilder.newTrigger().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
scheduler.scheduleJob(jobDetail, trigger);
} else {
// trigger已经存在,那么更细相应的定时设置
// 表达式调度构建器
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(job.getCronExpression());
// 按新的cronExpression表达式重新构建trigger
trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
// 按新的trigger重新设置job执行
scheduler.rescheduleJob(triggerKey, trigger);
}
}
}
代码示例来源:origin: sanluan/PublicCMS
trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).startNow()
.build();
scheduler.rescheduleJob(triggerKey, trigger);
代码示例来源:origin: sanluan/PublicCMS
trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).startNow()
.build();
scheduler.rescheduleJob(triggerKey, trigger);
代码示例来源:origin: bill1012/AdminEAP
.build();
scheduler.rescheduleJob(triggerKey, trigger);
代码示例来源:origin: bill1012/AdminEAP
/**
* 调度单个任务 SimpleTrigger 和 CronTrigger
*/
public void scheduleSingleJob(ScheduleJob job) throws SchedulerException, ClassNotFoundException {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
// List<ScheduleJob> jobList = getAllJobs();
TriggerKey triggerKey = TriggerKey.triggerKey(job.getTriggerName(), job.getTriggerGroup());
// 获取trigger
Trigger trigger = scheduler.getTrigger(triggerKey);
// 不存在,创建一个
// if (null == trigger) {
if (!scheduler.checkExists(triggerKey)) {
JobDetail jobDetail = JobBuilder.newJob((Class<? extends Job>) Class.forName(job.getJobClass()))
.withIdentity(job.getJobName(), job.getJobGroup()).withDescription(job.getDesc()).build();
TriggerBuilder triggerBuilder = TriggerBuilder.newTrigger();
trigger = setTriggerParam(job, triggerKey, triggerBuilder, trigger);
scheduler.scheduleJob(jobDetail, trigger);
} else {
// trigger已经存在,更新相应的定时设置
TriggerBuilder triggerBuilder = trigger.getTriggerBuilder();
trigger = setTriggerParam(job, triggerKey, triggerBuilder, trigger);
// 按新的trigger重新设置job执行
scheduler.rescheduleJob(triggerKey, trigger);
}
}
代码示例来源:origin: org.opensingular/singular-flow-schedule
/**
* Remove (delete) the <code>{@link org.quartz.Trigger}</code> with the
* given key, and store the new given one - which must be associated
* with the same job (the new trigger must have the job name & group specified)
* - however, the new trigger need not have the same name as the old trigger.
*
* @param trigger The new <code>Trigger</code> to be stored.
* @see Scheduler#rescheduleJob(TriggerKey, Trigger)
*/
private void rescheduleJob(Trigger trigger) throws SchedulerException {
getScheduler().rescheduleJob(trigger.getKey(), trigger);
}
代码示例来源:origin: org.opensingular/singular-schedule
/**
* Remove (delete) the <code>{@link org.quartz.Trigger}</code> with the
* given key, and store the new given one - which must be associated
* with the same job (the new trigger must have the job name & group specified)
* - however, the new trigger need not have the same name as the old trigger.
*
* @param trigger The new <code>Trigger</code> to be stored.
* @see Scheduler#rescheduleJob(TriggerKey, Trigger)
*/
private void rescheduleJob(Trigger trigger) throws SchedulerException {
getScheduler().rescheduleJob(trigger.getKey(), trigger);
}
代码示例来源:origin: stackoverflow.com
public void execute(JobExecutionContext context) throws JobExecutionException {
Trigger newTigger = what ever you want;
Trigger oldTrigger = context.getTrigger()
Scheduler scheduler = StdSchedulerFactory.getDefaultScheduler();
scheduler.rescheduleJob(oldTrigger.getKey(), newTrigger);
}
代码示例来源:origin: org.exoplatform.kernel/exo.kernel.component.common
public Date rescheduleJob(String jobName, String groupName, Trigger newTrigger) throws SchedulerException
{
return scheduler_.rescheduleJob(TriggerKey.triggerKey(jobName, getGroupName(groupName)), newTrigger
.getTriggerBuilder().withIdentity(jobName, getGroupName(groupName)).build());
}
内容来源于网络,如有侵权,请联系作者删除!