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