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


Java Scheduler.rescheduleJob方法代碼示例

本文整理匯總了Java中org.quartz.Scheduler.rescheduleJob方法的典型用法代碼示例。如果您正苦於以下問題:Java Scheduler.rescheduleJob方法的具體用法?Java Scheduler.rescheduleJob怎麽用?Java Scheduler.rescheduleJob使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.quartz.Scheduler的用法示例。


在下文中一共展示了Scheduler.rescheduleJob方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: modifyJobTime

import org.quartz.Scheduler; //導入方法依賴的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

示例2: updateJobTrigger

import org.quartz.Scheduler; //導入方法依賴的package包/類
@Transactional
@Override
public boolean updateJobTrigger(ScheduleJobEntity job) {
	try {
		Scheduler scheduler = schedulerFactoryBean.getScheduler();
		// 獲取觸發器標識
		TriggerKey triggerKey = job.getTriggerKey();
		CronTrigger trigger = (CronTrigger) scheduler.getTrigger(triggerKey);

		// Trigger已存在,更新相應的定時設置
		// 表達式調度構建器
		CronScheduleBuilder scheduleBuilder = CronScheduleBuilder
				.cronSchedule(job.getCronExpression());

		// 按新的cronExpression表達式重新構建trigger
		trigger = trigger.getTriggerBuilder()
				.forJob(job.getJobKey())
				.withIdentity(triggerKey)
				.startAt(job.getStartDate()) // job開始日期
				.endAt(job.getEndDate())// job結束日期
				.withSchedule(scheduleBuilder).build();
		// 按新的trigger重新設置job執行
		scheduler.rescheduleJob(triggerKey, trigger);
		return Boolean.TRUE;
	} catch (Exception e) {
		throw new ServiceException(e);
	}
}
 
開發者ID:wjggwm,項目名稱:webside,代碼行數:29,代碼來源:ScheduleJobServiceImpl.java

示例3: updateScheduleJob

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * 更新定時任務
 */
public static void updateScheduleJob(Scheduler scheduler, ScheduleJobEntity scheduleJob) {
    try {
        TriggerKey triggerKey = getTriggerKey(scheduleJob.getJobId());

        //表達式調度構建器
        CronScheduleBuilder scheduleBuilder = CronScheduleBuilder.cronSchedule(scheduleJob.getCronExpression())
        		.withMisfireHandlingInstructionDoNothing();

        CronTrigger trigger = getCronTrigger(scheduler, scheduleJob.getJobId());

        //按新的cronExpression表達式重新構建trigger
        trigger = trigger.getTriggerBuilder().withIdentity(triggerKey).withSchedule(scheduleBuilder).build();

        //參數
        trigger.getJobDataMap().put(ScheduleJobEntity.JOB_PARAM_KEY, new Gson().toJson(scheduleJob));

        scheduler.rescheduleJob(triggerKey, trigger);

        //暫停任務
        if(scheduleJob.getStatus() == ScheduleStatus.PAUSE.getValue()){
        	pauseJob(scheduler, scheduleJob.getJobId());
        }

    } catch (SchedulerException e) {
        throw new RRException("更新定時任務失敗", e);
    }
}
 
開發者ID:gyp220203,項目名稱:renren-msg,代碼行數:31,代碼來源:ScheduleUtils.java

示例4: updateTriggerForJob

import org.quartz.Scheduler; //導入方法依賴的package包/類
/**
 * 更新Trigger
 * @param schedulerName
 * @param trigger
 * @throws SchedulerException
 */
public void updateTriggerForJob(String schedulerName, Trigger trigger) throws SchedulerException {
    Assert.notNull(trigger, "trigger can not be null");
    Scheduler scheduler = this.getAssertScheduler(schedulerName);
    if (existTrigger(schedulerName, QuartzUtils.getTriggerName(trigger), QuartzUtils.getTriggerGroup(trigger))) {
        scheduler.rescheduleJob(trigger.getKey(), trigger);
    } else {
        throw new IllegalArgumentException("trigger [" + trigger.getKey().getName() +
                ":" + trigger.getKey().getGroup() + "] not exist");
    }
}
 
開發者ID:quartzweb,項目名稱:quartz-web,代碼行數:17,代碼來源:QuartzManager.java

示例5: updateJobCron

import org.quartz.Scheduler; //導入方法依賴的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

示例6: updateJobCron

import org.quartz.Scheduler; //導入方法依賴的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.Scheduler.rescheduleJob方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。