当前位置: 首页>>代码示例>>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;未经允许,请勿转载。