本文整理汇总了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;
}
示例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 );
}
}
}
示例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 );
}
}
示例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 );
}
}
示例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);
}