use of org.springframework.scheduling.quartz.CronTriggerFactoryBean in project series-rest-api by 52North.
the class JobUtils method createCronTrigger.
default CronTriggerFactoryBean createCronTrigger(JobDetail jobDetail, String cronExpression, String triggerName) {
getLogger().debug("createTrigger(jobDetail={}, cronExpression={}, triggerName={})", jobDetail.toString(), cronExpression, triggerName);
// To fix an issue with time-based cron jobs
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
CronTriggerFactoryBean factoryBean = new CronTriggerFactoryBean();
factoryBean.setJobDetail(jobDetail);
factoryBean.setCronExpression(cronExpression);
factoryBean.setStartTime(calendar.getTime());
factoryBean.setStartDelay(0L);
factoryBean.setName(triggerName);
factoryBean.setMisfireInstruction(CronTrigger.MISFIRE_INSTRUCTION_DO_NOTHING);
return factoryBean;
}
use of org.springframework.scheduling.quartz.CronTriggerFactoryBean in project kylo by Teradata.
the class SimpleSchedulerSetup method afterPropertiesSet.
@Override
public void afterPropertiesSet() throws Exception {
MethodInvokingJobDetailFactoryBean jobDetailFactory = new MethodInvokingJobDetailFactoryBean();
jobDetailFactory.setTargetObject(this.jobRunner);
jobDetailFactory.setTargetMethod(this.targetMethod);
jobDetailFactory.setName(this.jobName);
jobDetailFactory.setGroup(this.groupName);
jobDetailFactory.setConcurrent(concurrent);
applicationContext.getAutowireCapableBeanFactory().initializeBean(jobDetailFactory, UUID.randomUUID().toString());
CronTriggerFactoryBean triggerFactoryBean = new CronTriggerFactoryBean();
triggerFactoryBean.setCronExpression(cronExpression);
triggerFactoryBean.setJobDetail(jobDetailFactory.getObject());
triggerFactoryBean.setGroup(this.groupName);
if (this.jobName != null) {
triggerFactoryBean.setName("trigger_" + this.jobName);
}
applicationContext.getAutowireCapableBeanFactory().initializeBean(triggerFactoryBean, UUID.randomUUID().toString());
quartzScheduler.scheduleJob(jobDetailFactory, triggerFactoryBean);
}
Aggregations