当前位置: 首页>>代码示例>>Java>>正文


Java CronTrigger.setCronExpression方法代码示例

本文整理汇总了Java中org.quartz.CronTrigger.setCronExpression方法的典型用法代码示例。如果您正苦于以下问题:Java CronTrigger.setCronExpression方法的具体用法?Java CronTrigger.setCronExpression怎么用?Java CronTrigger.setCronExpression使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.quartz.CronTrigger的用法示例。


在下文中一共展示了CronTrigger.setCronExpression方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: JobRegist

import org.quartz.CronTrigger; //导入方法依赖的package包/类
public void JobRegist() throws Exception {
	Class<?> c = null;
	// 등록할 스케줄 정보 설정
	setSchList();

	for (int j = 0; j < schDTO.length; j++) {
		try {
			c = Class.forName(schDTO[j].getTask_class());

			jobDetail = new JobDetail(schDTO[j].getTask_id(), schDTO[j].getTask_group_id(), c);
			trigger = new CronTrigger(schDTO[j].getTask_id(), schDTO[j].getTask_group_id());

			trigger.setCronExpression(schDTO[j].getTask_expression());
			scheduler.scheduleJob(jobDetail, trigger);
		} catch (Exception e) {
			throw e;
		}
	}
}
 
开发者ID:iotoasis,项目名称:SDA,代码行数:20,代码来源:SchedulerMainService.java

示例2: JobRegist

import org.quartz.CronTrigger; //导入方法依赖的package包/类
public void JobRegist() throws Exception {
	Class c = null;
	// 등록할 스케줄 정보 설정
	setSchList();

	for (int j = 0; j < schDTO.length; j++) {
		try {
			c = Class.forName(schDTO[j].getTask_class());

			jobDetail = new JobDetail(schDTO[j].getTask_id(), schDTO[j].getTask_group_id(), c);
			trigger = new CronTrigger(schDTO[j].getTask_id(), schDTO[j].getTask_group_id());

			trigger.setCronExpression(schDTO[j].getTask_expression());
			scheduler.scheduleJob(jobDetail, trigger);
		} catch (Exception e) {
			throw e;
		}
	}
}
 
开发者ID:iotoasis,项目名称:SDA,代码行数:20,代码来源:SchedulerMainService.java

示例3: schedule

import org.quartz.CronTrigger; //导入方法依赖的package包/类
@Override
public void schedule(String jobName, CronExpression cronExpression) {
	 try  {   
		 if(jobDetail != null){
			 jobDetail.setName(jobName);
			 jobDetail.setGroup(JOB_GROUP_NAME);
             CronTrigger cronTrigger =  new  CronTrigger(jobName, TRIGGER_GROUP_NAME);
             cronTrigger.setCronExpression(cronExpression);    
             scheduler.scheduleJob(jobDetail,cronTrigger);
             if(!scheduler.isShutdown())
            	 scheduler.start();
		 }else{
			 log.error("定时任务  "+jobName+" jobDetail对象为空");
			 //System.out.println("定时任务  "+jobName+" jobDetail对象为空");
		 }
           // scheduler.rescheduleJob(name, Scheduler.DEFAULT_GROUP, cronTrigger);    
        }  catch  (SchedulerException e) {    
       	 log.error(e);
            throw new RuntimeException(e);    
        }    
}
 
开发者ID:wufeisoft,项目名称:data,代码行数:22,代码来源:SchedulerServiceImpl.java

示例4: modifyJob

import org.quartz.CronTrigger; //导入方法依赖的package包/类
public boolean modifyJob(String jobName, String cronExpression)
		throws SchedulerException, ParseException {
	boolean flag = false;
	CronTrigger trigger = (CronTrigger) scheduler.getTrigger(jobName,
			TRIGGER_GROUP_NAME);
	if (trigger != null) {
		if (StringUtils.equals(trigger.getCronExpression(), cronExpression)) {
			log.info(jobName + " : 定时任务表达式一致、不需要修改");
			flag = true;
		} else {
			trigger.setCronExpression(cronExpression);
			scheduler.rescheduleJob(trigger.getName(), trigger.getGroup(),
					trigger);
			log.info(jobName + " : 定时任务修改成功");
			flag = true;
		}
	}
	return flag;
}
 
开发者ID:wufeisoft,项目名称:data,代码行数:20,代码来源:SchedulerServiceImpl.java

示例5: addJob

import org.quartz.CronTrigger; //导入方法依赖的package包/类
/**
 * 添加一个定时任务,使用默认的任务组名,触发器名,触发器组名
 *
 * @param jobName
 *            任务名
 * @param jobClass
 *            任务
 * @param time
 *            时间设置,参考quartz说明文档
 * @throws SchedulerException
 * @throws ParseException
 */
public static void addJob(String jobName, String jobClass, String time) {
	try {
		Scheduler sched = gSchedulerFactory.getScheduler();
		JobDetail jobDetail = new JobDetail(jobName, JOB_GROUP_NAME, Class.forName(jobClass));// 任务名,任务组,任务执行类
		// 触发器
		CronTrigger trigger = new CronTrigger(jobName, TRIGGER_GROUP_NAME);// 触发器名,触发器组
		trigger.setCronExpression(time);// 触发器时间设定
		sched.scheduleJob(jobDetail, trigger);
		// 启动
		if (!sched.isShutdown()){
			sched.start();
		}
	} catch (Exception e) {
		e.printStackTrace();
		throw new RuntimeException(e);
	}
}
 
开发者ID:yancykim,项目名称:support,代码行数:30,代码来源:QuartzManager.java

示例6: modifyJobTime

import org.quartz.CronTrigger; //导入方法依赖的package包/类
/**
 * 修改一个任务的触发时间
 *
 * @param triggerName
 * @param triggerGroupName
 * @param time
 */
public static void modifyJobTime(String triggerName,
		String triggerGroupName, String time) {
	try {
		Scheduler sched = gSchedulerFactory.getScheduler();
		CronTrigger trigger = (CronTrigger) sched.getTrigger(triggerName, triggerGroupName);
		if(trigger == null) {
			return;
		}
		String oldTime = trigger.getCronExpression();
		if (!oldTime.equalsIgnoreCase(time)) {
			CronTrigger ct = (CronTrigger) trigger;
			// 修改时间
			ct.setCronExpression(time);
			// 重启触发器
			sched.resumeTrigger(triggerName, triggerGroupName);
		}
	} catch (Exception e) {
		e.printStackTrace();
		throw new RuntimeException(e);
	}
}
 
开发者ID:yancykim,项目名称:support,代码行数:29,代码来源:QuartzManager.java

示例7: startTask

import org.quartz.CronTrigger; //导入方法依赖的package包/类
/**
 * 开始任务调度
 * @param task 任务
 * @param taskCode 任务名称
 * @throws ParseException
 * @throws SchedulerException
 * @throws ClassNotFoundException
 */
private void startTask(CmsTask task,String taskCode) throws ParseException, SchedulerException, ClassNotFoundException{
	String cronExpress=manager.getCronExpressionFromDB(task.getId());
	System.out.println(cronExpress);
	if(cronExpress.indexOf("null")==-1){
		JobDetail jobDetail = new JobDetail();
		jobDetail.setName(taskCode);
		jobDetail.setGroup(Scheduler.DEFAULT_GROUP);
		jobDetail.setJobClass(getClassByTask(task.getJobClass()));
		//任务需要参数attr属性 
		jobDetail.setJobDataMap(getJobDataMap(task.getAttr()));
		CronTrigger cronTrigger = new CronTrigger("cron_" + taskCode,Scheduler.DEFAULT_GROUP, jobDetail.getName(),Scheduler.DEFAULT_GROUP);
		cronTrigger.setCronExpression(cronExpress);
		scheduler.scheduleJob(jobDetail, cronTrigger); 
	}
}
 
开发者ID:caipiao,项目名称:Lottery,代码行数:24,代码来源:CmsTaskAct.java

示例8: validate

import org.quartz.CronTrigger; //导入方法依赖的package包/类
/**
 * Helper method to validate schedule item
 *
 * @return true if valid, otherwise returns false
 */
public static boolean validate(final ScheduleItem item) {
  final CronTrigger cronTrigger = new CronTrigger();
  try {
    final String[] ce = toString(item);
    for (int i = 0; i < ce.length; i++) {
      cronTrigger.setCronExpression(ce[i]);
    }
    return true;
  } catch (ParseException e) {
    return false;
  }
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:18,代码来源:ScheduleItem.java

示例9: makeCronTriggers

import org.quartz.CronTrigger; //导入方法依赖的package包/类
/**
 * Helper method to create cron trigger
 */
public static CronTrigger[] makeCronTriggers(final int buildID, final ScheduleItem item) throws ParseException {
  final String[] cronExpressions = ScheduleItem.toString(item);
  final CronTrigger[] result = new CronTrigger[cronExpressions.length];
  for (int i = 0; i < cronExpressions.length; i++) {
    final CronTrigger trigger = new CronTrigger();
    trigger.setCronExpression(cronExpressions[i]);
    trigger.setGroup(makeGroupName(buildID));
    trigger.setStartTime(new Date());
    result[i] = trigger;
  }
  return result;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:16,代码来源:RepeatableScheduler.java

示例10: init

import org.quartz.CronTrigger; //导入方法依赖的package包/类
public void init(ServletConfig config) throws ServletException
{
	 SchedulerConfiguration configuration = SchedulerConfiguration.getInstance();
	 boolean schedule = Boolean.valueOf( configuration.get( "scheduler.schedule" ) ).booleanValue();
	 String cronExpression = configuration.get( "scheduler.cron.expression" );
	 
	 _log.info( "SCHEDULE [" + schedule + "]" );
	 _log.info( "TIME EXPRESSION [" + cronExpression + "]" );
	 
	 if ( schedule )
	 {
		 StdSchedulerFactory schedFact = this.getSchedulerFactory( config );
		 CronTrigger trigger = new CronTrigger(NAME, GROUP);
		 try 
		 {
			 JobDetail jobDetail = new JobDetail( NAME, GROUP, GeneracionEstadisticasJob.class );
			 trigger.setCronExpression( cronExpression );
			 //				 Retrasamos 2 minutos
			 java.util.Date startTime = new java.util.Date();					
			 startTime.setTime( startTime.getTime() + ( SCHEDULER_DELAY_MINUTES * 60 * 1000 ) );
			 _log.debug( "Job " + NAME + ": Fecha de inicio[ " + startTime + "]");
			 trigger.setStartTime( startTime );
			 //Scheduler sched = schedFact.getDefaultScheduler();
			 sched = schedFact.getScheduler();
			 //sched.addJobListener( new AuditJobListener() );
			 sched.scheduleJob( jobDetail, trigger );
		 }
		 catch (Exception e) 
		 {
		  	_log.error( "Exception scheduling : ", e );			
		 }
	 }
}
 
开发者ID:GovernIB,项目名称:sistra,代码行数:34,代码来源:AuditaSchedulerServlet.java

示例11: startTask

import org.quartz.CronTrigger; //导入方法依赖的package包/类
/**
 * 开始任务调度
 * @param task 任务
 * @param taskCode 任务名称
 * @throws ParseException
 * @throws SchedulerException
 * @throws ClassNotFoundException
 */
private void startTask(CmsTask task,String taskCode) throws ParseException, SchedulerException, ClassNotFoundException{
	String cronExpress=manager.getCronExpressionFromDB(task.getId());
	if(cronExpress.indexOf("null")==-1){
		JobDetail jobDetail = new JobDetail();
		jobDetail.setName(taskCode);
		jobDetail.setGroup(Scheduler.DEFAULT_GROUP);
		jobDetail.setJobClass(getClassByTask(task.getJobClass()));
		//任务需要参数attr属性 
		jobDetail.setJobDataMap(getJobDataMap(task.getAttr()));
		CronTrigger cronTrigger = new CronTrigger("cron_" + taskCode,Scheduler.DEFAULT_GROUP, jobDetail.getName(),Scheduler.DEFAULT_GROUP);
		cronTrigger.setCronExpression(cronExpress);
		scheduler.scheduleJob(jobDetail, cronTrigger); 
	}
}
 
开发者ID:huanzhou,项目名称:jeecms6,代码行数:23,代码来源:CmsTaskAct.java

示例12: getTrigger

import org.quartz.CronTrigger; //导入方法依赖的package包/类
private CronTrigger getTrigger(String name, String group, String cronExpression) throws ParseException{
	CronTrigger trigger = new CronTrigger();
	trigger.setCronExpression(cronExpression);
	trigger.setName(name);
	trigger.setGroup(group);
	return trigger;
}
 
开发者ID:cheetah100,项目名称:gravity,代码行数:8,代码来源:TimerManager.java

示例13: refreshTrigger

import org.quartz.CronTrigger; //导入方法依赖的package包/类
public static void refreshTrigger(String name, String triggerStr)
		throws ParseException, SchedulerException {
	CronTrigger trigger = (CronTrigger) sched.getTrigger(name + "_trigger",
			Scheduler.DEFAULT_GROUP);
	trigger.setCronExpression(triggerStr);
	sched
			.rescheduleJob(name + "_trigger", Scheduler.DEFAULT_GROUP,
					trigger);
}
 
开发者ID:xiangtao,项目名称:timeschedule,代码行数:10,代码来源:QuartzScheduleWrapper.java

示例14: createCronTrigger

import org.quartz.CronTrigger; //导入方法依赖的package包/类
/**
 * Make a cron trigger via the cron expression
 * @param value
 * @return
 * @throws InvalidTriggerException
 */
public static Trigger createCronTrigger(String name, String value) throws InvalidTriggerException{
	CronTrigger ct = new CronTrigger();
	try {
		ct.setName(name);
		ct.setCronExpression(value);
	} catch (ParseException e) {
		log.error("",e);
		throw new InvalidTriggerException("invalid cron expression '"+value+"'");
	}
	return ct;
}
 
开发者ID:xiangtao,项目名称:timeschedule,代码行数:18,代码来源:TriggerFactory.java

示例15: scheduleJob

import org.quartz.CronTrigger; //导入方法依赖的package包/类
public void scheduleJob(JobDetail jobDetail, String cronExpression, long interval, boolean overwrite) throws SchedulerException, ParseException {
	Scheduler sched = getScheduler();

	// if the job already exists, remove it.
	if ((sched.getTrigger(jobDetail.getName(), jobDetail.getGroup())) != null) {
		if (overwrite)
			sched.unscheduleJob(jobDetail.getName(), jobDetail.getGroup());
		else
			throw new SchedulerException("Job with name [" + jobDetail.getName() + "] already exists");
	}

	if (StringUtils.isNotEmpty(cronExpression)) {
		CronTrigger cronTrigger = new CronTrigger(jobDetail.getName(), jobDetail.getGroup());
		cronTrigger.setCronExpression(cronExpression);
		sched.scheduleJob(jobDetail, cronTrigger);
	} else if (interval > -1) {
		SimpleTrigger simpleTrigger = new SimpleTrigger(jobDetail.getName(), jobDetail.getGroup());
		if (interval == 0) {
			// Keep trigger active to keep it available in GUI
			simpleTrigger.setRepeatCount(1);
			simpleTrigger.setRepeatInterval(1000L * 60L * 60L * 24L * 365L * 100L);
		} else {
			// New Quartz version seems to have repeatForever(), for now set
			// repeat count to Integer.MAX_VALUE.
			simpleTrigger.setRepeatCount(Integer.MAX_VALUE);
			simpleTrigger.setRepeatInterval(interval);
		}
		sched.scheduleJob(jobDetail, simpleTrigger);
	} else {
		log.warn("no cronexpression or interval for job [" + jobDetail.getName() + "], cannot schedule");
	}
}
 
开发者ID:ibissource,项目名称:iaf,代码行数:33,代码来源:SchedulerHelper.java


注:本文中的org.quartz.CronTrigger.setCronExpression方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。