當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。