本文整理匯總了Java中org.quartz.TriggerKey.triggerKey方法的典型用法代碼示例。如果您正苦於以下問題:Java TriggerKey.triggerKey方法的具體用法?Java TriggerKey.triggerKey怎麽用?Java TriggerKey.triggerKey使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.quartz.TriggerKey
的用法示例。
在下文中一共展示了TriggerKey.triggerKey方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: removeJob
import org.quartz.TriggerKey; //導入方法依賴的package包/類
/**
* @Description 移除一個任務(使用默認的任務組名,觸發器名,觸發器組名)
* @param jobName
*
*
*/
public static void removeJob(String jobName) {
TriggerKey triggerKey = TriggerKey.triggerKey(
jobName, TRIGGER_GROUP_NAME);
JobKey jobKey = JobKey.jobKey(jobName, JOB_GROUP_NAME);
try {
Scheduler sched = gSchedulerFactory.getScheduler();
Trigger trigger = (Trigger) sched.getTrigger(triggerKey);
if (trigger == null) {
return;
}
sched.pauseTrigger(triggerKey);;// 停止觸發器
sched.unscheduleJob(triggerKey);// 移除觸發器
sched.deleteJob(jobKey);// 刪除任務
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例2: modifyJobTime
import org.quartz.TriggerKey; //導入方法依賴的package包/類
/**
* @Description: 修改一個任務的觸發時間(使用默認的任務組名,觸發器名,觸發器組名)
* @param jobName
* @param time
*
*/
@SuppressWarnings("unchecked")
public static void modifyJobTime(String jobName, String time) {
TriggerKey triggerKey = TriggerKey.triggerKey(
jobName, TRIGGER_GROUP_NAME);
try {
Scheduler sched = gSchedulerFactory.getScheduler();
CronTrigger trigger =(CronTrigger) sched.getTrigger(triggerKey);
if (trigger == null) {
return;
}
String oldTime = trigger.getCronExpression();
if (!oldTime.equalsIgnoreCase(time)) {
CronScheduleBuilder scheduleBuilder =CronScheduleBuilder.cronSchedule(time);
//按新的cronExpression表達式重新構建trigger
trigger = trigger.getTriggerBuilder().withIdentity(triggerKey)
.withSchedule(scheduleBuilder).build();
//按新的trigger重新設置job執行
sched.rescheduleJob(triggerKey, trigger);
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
示例3: addJob
import org.quartz.TriggerKey; //導入方法依賴的package包/類
private void addJob(ScheduleJob scheduleJob) throws Exception{
checkNotNull(scheduleJob);
Preconditions.checkNotNull(StringUtils.isEmpty(scheduleJob.getCronExpression()), "CronExpression is null");
TriggerKey triggerKey = TriggerKey.triggerKey(scheduleJob.getJobName(), scheduleJob.getJobGroup());
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
if(trigger != null){
throw new Exception("job already exists!");
}
// simulate job info db persist operation
scheduleJob.setJobId(String.valueOf(QuartzJobFactory.jobList.size()+1));
QuartzJobFactory.jobList.add(scheduleJob);
JobDetail jobDetail = JobBuilder.newJob(QuartzJobFactory.class).withIdentity(scheduleJob.getJobName(),scheduleJob.getJobGroup()).build();
jobDetail.getJobDataMap().put("scheduleJob", scheduleJob);
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression());
trigger = TriggerBuilder.newTrigger().withIdentity(scheduleJob.getJobName(), scheduleJob.getJobGroup()).withSchedule(cronScheduleBuilder).build();
scheduler.scheduleJob(jobDetail, trigger);
}
示例4: updateJobCronExpression
import org.quartz.TriggerKey; //導入方法依賴的package包/類
private void updateJobCronExpression(ScheduleJob scheduleJob) throws SchedulerException{
checkNotNull(scheduleJob);
Preconditions.checkNotNull(StringUtils.isEmpty(scheduleJob.getCronExpression()), "CronExpression is null");
TriggerKey triggerKey = TriggerKey.triggerKey(scheduleJob.getJobName(), scheduleJob.getJobGroup());
CronTrigger cronTrigger = (CronTrigger)scheduler.getTrigger(triggerKey);
CronScheduleBuilder cronScheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression());
cronTrigger = cronTrigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(cronScheduleBuilder).build();
scheduler.rescheduleJob(triggerKey, cronTrigger);
}
示例5: getTriggerKey
import org.quartz.TriggerKey; //導入方法依賴的package包/類
/**
* 獲取觸發器key
*/
public static TriggerKey getTriggerKey(Long jobId) {
return TriggerKey.triggerKey(JOB_NAME + jobId);
}
示例6: stopJob
import org.quartz.TriggerKey; //導入方法依賴的package包/類
public void stopJob(TaskScheduled scheduleJob) {
try {
TriggerKey triggerKey = TriggerKey.triggerKey(scheduleJob.getTaskName(), scheduleJob.getTaskGroup());
scheduler.pauseTrigger(triggerKey);
} catch (Exception e) {
logger.error("Try to stop Job cause error : ", e);
throw new BusinessException(e);
}
}
示例7: resumeJob
import org.quartz.TriggerKey; //導入方法依賴的package包/類
public void resumeJob(TaskScheduled scheduleJob) {
try {
TriggerKey triggerKey = TriggerKey.triggerKey(scheduleJob.getTaskName(), scheduleJob.getTaskGroup());
scheduler.resumeTrigger(triggerKey);
} catch (Exception e) {
logger.error("Try to resume Job cause error : ", e);
throw new BusinessException(e);
}
}
示例8: delJob
import org.quartz.TriggerKey; //導入方法依賴的package包/類
public void delJob(TaskScheduled scheduleJob) {
try {
JobKey jobKey = JobKey.jobKey(scheduleJob.getTaskName(), scheduleJob.getTaskGroup());
TriggerKey triggerKey = TriggerKey.triggerKey(scheduleJob.getTaskName(), scheduleJob.getTaskGroup());
scheduler.pauseTrigger(triggerKey);// 停止觸發器
scheduler.unscheduleJob(triggerKey);// 移除觸發器
scheduler.deleteJob(jobKey);// 刪除任務
} catch (Exception e) {
logger.error("Try to resume Job cause error : ", e);
throw new BusinessException(e);
}
}
示例9: updateJobCron
import org.quartz.TriggerKey; //導入方法依賴的package包/類
/**
* 更新job時間表達式
*
* @param scheduleJob
* @throws SchedulerException
*/
public void updateJobCron(ScheduleJob scheduleJob) throws SchedulerException {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
TriggerKey triggerKey = TriggerKey.triggerKey(scheduleJob.getJobName(), scheduleJob.getJobGroup());
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression());
trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
scheduler.rescheduleJob(triggerKey, trigger);
}
示例10: getTriggerKey
import org.quartz.TriggerKey; //導入方法依賴的package包/類
/**
*
* @Title: getTriggerKey
* @Description: 生成triggerKey
* @return TriggerKey
* @throws
*/
public TriggerKey getTriggerKey() {
if (triggerKey == null && this.triggerName !=null && this.triggerGroup != null) {
triggerKey = TriggerKey.triggerKey(getTriggerName(),getTriggerGroup());
}
return triggerKey;
}
示例11: updateJobCron
import org.quartz.TriggerKey; //導入方法依賴的package包/類
/**
* 更新job時間表達式
*
* @param scheduleJob
* @throws SchedulerException
*/
public void updateJobCron(ScheduleJob scheduleJob) throws SchedulerException {
Scheduler scheduler = schedulerFactoryBean.getScheduler();
TriggerKey triggerKey = TriggerKey.triggerKey(scheduleJob.getName(), scheduleJob.getGroup());
CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);
CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCron());
trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();
scheduler.rescheduleJob(triggerKey, trigger);
}