當前位置: 首頁>>代碼示例>>Java>>正文


Java TriggerKey.triggerKey方法代碼示例

本文整理匯總了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);    
    }    
}
 
開發者ID:jeffreyning,項目名稱:nh-micro,代碼行數:24,代碼來源:MicroQuartzManager.java

示例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);    
    }    
}
 
開發者ID:jeffreyning,項目名稱:nh-micro,代碼行數:31,代碼來源:MicroQuartzManager.java

示例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);  

  }
 
開發者ID:jiwenxing,項目名稱:springboot-quartz,代碼行數:24,代碼來源:ScheduleJobService.java

示例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);  
  }
 
開發者ID:jiwenxing,項目名稱:springboot-quartz,代碼行數:11,代碼來源:ScheduleJobService.java

示例5: getTriggerKey

import org.quartz.TriggerKey; //導入方法依賴的package包/類
/**
 * 獲取觸發器key
 */
public static TriggerKey getTriggerKey(Long jobId) {
    return TriggerKey.triggerKey(JOB_NAME + jobId);
}
 
開發者ID:gyp220203,項目名稱:renren-msg,代碼行數:7,代碼來源:ScheduleUtils.java

示例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);
    }
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:10,代碼來源:SchedulerManager.java

示例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);
    }
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:10,代碼來源:SchedulerManager.java

示例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);
    }
}
 
開發者ID:iBase4J,項目名稱:iBase4J-Common,代碼行數:13,代碼來源:SchedulerManager.java

示例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);
}
 
開發者ID:handexing,項目名稱:frameworkAggregate,代碼行數:15,代碼來源:ScheduleJobService.java

示例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;
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:14,代碼來源:ScheduleJobEntity.java

示例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);
}
 
開發者ID:Zigin,項目名稱:MonitorPlatform,代碼行數:20,代碼來源:JobConfigService.java


注:本文中的org.quartz.TriggerKey.triggerKey方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。