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


Java CronTrigger.setStartTime方法代碼示例

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


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

示例1: 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

示例2: 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

示例3: init

import org.quartz.CronTrigger; //導入方法依賴的package包/類
public void init(ServletConfig config) throws ServletException
{
	try 
	{
		boolean jobSchedule;
		String jobName,jobCron,jobClassName;
		int jobNumber;
				
		// Prepraramos scheduler
		SchedulerConfiguration configuration = SchedulerConfiguration.getInstance();
		StdSchedulerFactory schedFact = this.getSchedulerFactory( config );
		sched = schedFact.getScheduler();
		//ssched.addJobListener( new MobtratelJobListener() );
		
		// Programaci�n Jobs
		jobNumber = Integer.parseInt(configuration.get( "scheduler.jobs.number" ));
		for (int i=1;i<=jobNumber;i++){
			jobName = configuration.get( "scheduler.job." + i + ".name" );
			jobClassName = configuration.get( "scheduler.job." + i + ".classname" );
			jobSchedule = Boolean.valueOf( configuration.get( "scheduler.job." + i + ".schedule" ) ).booleanValue();
			jobCron = configuration.get( "scheduler.job." + i + ".cron.expression" );
			
			_log.debug(jobName + ": Schedule? " + jobSchedule );
			_log.debug(jobName + ": Cron? " + jobCron );
			 
			 if ( jobSchedule )
			 {				 
				CronTrigger trigger = new CronTrigger(jobName, GROUP);
				JobDetail jobDetail = new JobDetail( jobName, GROUP, Class.forName(jobClassName));
				trigger.setCronExpression( jobCron );
				// Retrasamos 2 minutos
				java.util.Date startTime = new java.util.Date();					
				startTime.setTime( startTime.getTime() + ( SCHEDULER_DELAY_MINUTES * 60 * 1000 ) );
				_log.debug( "Job " + jobName + ": Fecha de inicio[ " + startTime + "]");
				trigger.setStartTime( startTime );
				sched.scheduleJob( jobDetail, trigger );				
			 }
		}
	
	 }
	 catch (Exception e) 
	 {
	  	_log.error( "Exception scheduling : ", e );
	 }
			 
}
 
開發者ID:GovernIB,項目名稱:sistra,代碼行數:47,代碼來源:MobtratelSchedulerServlet.java

示例4: init

import org.quartz.CronTrigger; //導入方法依賴的package包/類
public void init(ServletConfig config) throws ServletException
{
	try 
	{
		boolean jobSchedule;
		String jobName,jobCron,jobClassName;
		int jobNumber;
				
		// Prepraramos scheduler
		SchedulerConfiguration configuration = SchedulerConfiguration.getInstance();
		StdSchedulerFactory schedFact = this.getSchedulerFactory( config );
		sched = schedFact.getScheduler();
		//sched.addJobListener( new BantelJobListener() );
		
		// Programaci�n Jobs
		jobNumber = Integer.parseInt(configuration.get( "scheduler.jobs.number" ));
		for (int i=1;i<=jobNumber;i++){
			jobName = configuration.get( "scheduler.job." + i + ".name" );
			jobClassName = configuration.get( "scheduler.job." + i + ".classname" );
			jobSchedule = Boolean.valueOf( configuration.get( "scheduler.job." + i + ".schedule" ) ).booleanValue();
			jobCron = configuration.get( "scheduler.job." + i + ".cron.expression" );
			
			_log.debug(jobName + ": Schedule? " + jobSchedule );
			_log.debug(jobName + ": Cron? " + jobCron );
			 
			 if ( jobSchedule )
			 {				 
				CronTrigger trigger = new CronTrigger(jobName, GROUP);
				JobDetail jobDetail = new JobDetail( jobName, GROUP, Class.forName(jobClassName));
				trigger.setCronExpression( jobCron );
				// Retrasamos 2 minutos
				java.util.Date startTime = new java.util.Date();					
				startTime.setTime( startTime.getTime() + ( SCHEDULER_DELAY_MINUTES * 60 * 1000 ) );
				_log.debug( "Job " + jobName + ": Fecha de inicio[ " + startTime + "]");
				trigger.setStartTime( startTime );
				sched.scheduleJob( jobDetail, trigger );				
			 }
		}
	
	 }
	 catch (Exception e) 
	 {
	  	_log.error( "Exception scheduling : ", e );
	 }
			 
}
 
開發者ID:GovernIB,項目名稱:sistra,代碼行數:47,代碼來源:BantelSchedulerServlet.java

示例5: testSchedulerFactoryBeanWithPlainQuartzObjects

import org.quartz.CronTrigger; //導入方法依賴的package包/類
@Test
public void testSchedulerFactoryBeanWithPlainQuartzObjects() throws Exception {
	JobFactory jobFactory = new AdaptableJobFactory();

	TestBean tb = new TestBean("tb", 99);
	JobDetail jobDetail0 = new JobDetail();
	jobDetail0.setJobClass(Job.class);
	jobDetail0.setName("myJob0");
	jobDetail0.setGroup(Scheduler.DEFAULT_GROUP);
	jobDetail0.getJobDataMap().put("testBean", tb);
	assertEquals(tb, jobDetail0.getJobDataMap().get("testBean"));

	CronTrigger trigger0 = new CronTrigger();
	trigger0.setName("myTrigger0");
	trigger0.setGroup(Scheduler.DEFAULT_GROUP);
	trigger0.setJobName("myJob0");
	trigger0.setJobGroup(Scheduler.DEFAULT_GROUP);
	trigger0.setStartTime(new Date());
	trigger0.setCronExpression("0/1 * * * * ?");

	TestMethodInvokingTask task1 = new TestMethodInvokingTask();
	MethodInvokingJobDetailFactoryBean mijdfb = new MethodInvokingJobDetailFactoryBean();
	mijdfb.setName("myJob1");
	mijdfb.setGroup(Scheduler.DEFAULT_GROUP);
	mijdfb.setTargetObject(task1);
	mijdfb.setTargetMethod("doSomething");
	mijdfb.afterPropertiesSet();
	JobDetail jobDetail1 = mijdfb.getObject();

	SimpleTrigger trigger1 = new SimpleTrigger();
	trigger1.setName("myTrigger1");
	trigger1.setGroup(Scheduler.DEFAULT_GROUP);
	trigger1.setJobName("myJob1");
	trigger1.setJobGroup(Scheduler.DEFAULT_GROUP);
	trigger1.setStartTime(new Date());
	trigger1.setRepeatCount(SimpleTrigger.REPEAT_INDEFINITELY);
	trigger1.setRepeatInterval(20);

	final Scheduler scheduler = mock(Scheduler.class);
	given(scheduler.scheduleJob(trigger0)).willReturn(new Date());
	given(scheduler.scheduleJob(trigger1)).willReturn(new Date());

	SchedulerFactoryBean schedulerFactoryBean = new SchedulerFactoryBean() {
		@Override
		protected Scheduler createScheduler(SchedulerFactory schedulerFactory, String schedulerName) {
			return scheduler;
		}
	};
	schedulerFactoryBean.setJobFactory(jobFactory);
	schedulerFactoryBean.setJobDetails(new JobDetail[] {jobDetail0, jobDetail1});
	schedulerFactoryBean.setTriggers(new Trigger[] {trigger0, trigger1});
	try {
		schedulerFactoryBean.afterPropertiesSet();
		schedulerFactoryBean.start();
	}
	finally {
		schedulerFactoryBean.destroy();
	}

	verify(scheduler).setJobFactory(jobFactory);
	verify(scheduler).getJobDetail("myJob0", Scheduler.DEFAULT_GROUP);
	verify(scheduler).getJobDetail("myJob1", Scheduler.DEFAULT_GROUP);
	verify(scheduler).getTrigger("myTrigger0", Scheduler.DEFAULT_GROUP);
	verify(scheduler).getTrigger("myTrigger1", Scheduler.DEFAULT_GROUP);
	verify(scheduler).addJob(jobDetail0, true);
	verify(scheduler).addJob(jobDetail1, true);
	verify(scheduler).scheduleJob(trigger0);
	verify(scheduler).scheduleJob(trigger1);
	verify(scheduler).start();
	verify(scheduler).shutdown(false);
}
 
開發者ID:deathspeeder,項目名稱:class-guard,代碼行數:72,代碼來源:QuartzSupportTests.java


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