Java Code Examples for org.springframework.scheduling.quartz.CronTriggerFactoryBean#setJobDetail()

The following examples show how to use org.springframework.scheduling.quartz.CronTriggerFactoryBean#setJobDetail() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JobScheduler.java    From DataHubSystem with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public void afterPropertiesSet () throws Exception
{
   Map<String, AbstractJob> webappBeanNames =
      applicationContext.getBeansOfType (AbstractJob.class);
   triggers = new HashMap<> ();
   for (String webappBeanName : webappBeanNames.keySet ())
   {
      AbstractJob cron = webappBeanNames.get (webappBeanName);
      CronTriggerFactoryBean trigger = new CronTriggerFactoryBean ();
      JobDetail job = JobBuilder.newJob (cron.getClass ()).
         storeDurably (true).build ();
      trigger.setJobDetail (job);
      trigger.setCronExpression (cron.getCronExpression ());
      trigger.setName (webappBeanName + "Trigger");
      trigger.afterPropertiesSet ();
      triggers.put (cron.getClass(), trigger.getObject ());
   }
   super.setTriggers (triggers.values ().toArray (
      new Trigger[triggers.size ()]));
   super.setJobFactory (autowiringJobFactory);
   super.afterPropertiesSet ();
}
 
Example 2
Source File: QuartzConfigration.java    From Tbed with GNU Affero General Public License v3.0 5 votes vote down vote up
@Bean(name = "secondTrigger")
public CronTriggerFactoryBean secondTrigger(JobDetail secondJobDetail) {
    CronTriggerFactoryBean trigger = new CronTriggerFactoryBean();
    trigger.setJobDetail(secondJobDetail);
    // cron表达式
    trigger.setCronExpression(Expression);
    //trigger.setCronExpression("0 0/1 * * * ?");
    return trigger;
}
 
Example 3
Source File: PacmanQuartzConfiguration.java    From pacbot with Apache License 2.0 5 votes vote down vote up
public CronTriggerFactoryBean createCronTrigger(JobDetail jobDetail, String cronExpression) {
	CronTriggerFactoryBean factoryBean = new CronTriggerFactoryBean();
	factoryBean.setJobDetail(jobDetail);
	factoryBean.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles"));
	factoryBean.setCronExpression(cronExpression);
	factoryBean.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW);
	return factoryBean;
}
 
Example 4
Source File: SchedulerConfig.java    From zkdoctor with Apache License 2.0 5 votes vote down vote up
/**
 * 创建cron触发器
 *
 * @param jobDetail      job信息
 * @param cronExpression cron表达式
 * @param triggerName    触发器名称
 * @param triggerGroup   触发器组
 * @return
 */
private CronTriggerFactoryBean createCronTrigger(JobDetail jobDetail, String cronExpression,
                                                 String triggerName, String triggerGroup) {
    CronTriggerFactoryBean factoryBean = new CronTriggerFactoryBean();
    factoryBean.setJobDetail(jobDetail);
    factoryBean.setName(triggerName);
    factoryBean.setGroup(triggerGroup);
    factoryBean.setCronExpression(cronExpression);
    factoryBean.setMisfireInstruction(SimpleTrigger.MISFIRE_INSTRUCTION_FIRE_NOW);
    return factoryBean;
}
 
Example 5
Source File: SpringBootAsyncProducerApplication.java    From Spring-Boot-2.0-Projects with MIT License 5 votes vote down vote up
@Bean
public CronTriggerFactoryBean trigger(JobDetail job, @Value("${images.cron}") String imagesCron) {
    CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
    cronTriggerFactoryBean.setCronExpression(imagesCron);
    cronTriggerFactoryBean.setJobDetail(job);
    return cronTriggerFactoryBean;
}
 
Example 6
Source File: QuartzConfigration.java    From springBoot-study with Apache License 2.0 5 votes vote down vote up
@Bean(name = "jobTrigger")  
    public CronTriggerFactoryBean cronJobTrigger(MethodInvokingJobDetailFactoryBean jobDetail) {  
        CronTriggerFactoryBean tigger = new CronTriggerFactoryBean();  
        tigger.setJobDetail(jobDetail.getObject());  
//        tigger.setCronExpression("0/30 * * * * ?");// 表示每隔30秒钟执行一次
        tigger.setCronExpression("1/30 * * * * ?");// 表示每隔30秒钟执行一次
        //tigger.set
        tigger.setName("myTigger");// trigger的name  
        return tigger;  

    }
 
Example 7
Source File: QuartzConfiguration.java    From multiapps-controller with Apache License 2.0 5 votes vote down vote up
@Inject
@Bean
public CronTriggerFactoryBean cleanUpCronTriggerFactoryBean(ApplicationConfiguration configuration) {
    CronTriggerFactoryBean factory = new CronTriggerFactoryBean();
    factory.setJobDetail(cleanUpJobDetail().getObject());
    factory.setCronExpression(configuration.getCronExpressionForOldData());
    factory.setMisfireInstruction(org.quartz.CronTrigger.MISFIRE_INSTRUCTION_FIRE_ONCE_NOW);
    factory.setGroup(TRIGGER_GROUP);
    factory.setName(CLEAN_UP_TRIGGER_NAME);
    return factory;
}
 
Example 8
Source File: QuartzConfig.java    From lemonaid with MIT License 5 votes vote down vote up
@Bean
public CronTriggerFactoryBean gravatarTrigger() {
	CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
	cronTriggerFactoryBean.setJobDetail(gravatarJob().getObject());
	cronTriggerFactoryBean.setCronExpression("0 30 * * * ?"); // Every hour
	cronTriggerFactoryBean.setGroup("lemonaid-quartz");
	return cronTriggerFactoryBean;
}
 
Example 9
Source File: QuartzConfig.java    From lemonaid with MIT License 5 votes vote down vote up
@Bean
public CronTriggerFactoryBean locationTrigger() {
	CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
	cronTriggerFactoryBean.setJobDetail(locationJob().getObject());
	cronTriggerFactoryBean.setCronExpression("0 15 0 * * ?"); // Every day
	cronTriggerFactoryBean.setGroup("lemonaid-quartz");
	return cronTriggerFactoryBean;
}
 
Example 10
Source File: QuartzConfig.java    From lemonaid with MIT License 5 votes vote down vote up
@Bean
public CronTriggerFactoryBean insideTrackTrigger() {
	CronTriggerFactoryBean cronTriggerFactoryBean = new CronTriggerFactoryBean();
	cronTriggerFactoryBean.setJobDetail(insideTrackJob().getObject());
	cronTriggerFactoryBean.setCronExpression("0 0 * * * ?"); // Every hour
	cronTriggerFactoryBean.setGroup("lemonaid-quartz");
	return cronTriggerFactoryBean;
}
 
Example 11
Source File: RepositoryStatisticsCronJob.java    From mojito with Apache License 2.0 5 votes vote down vote up
@Bean
public CronTriggerFactoryBean triggerRepositoryStatisticsCron(@Qualifier("repositoryStatisticsCron") JobDetail job) {
    CronTriggerFactoryBean trigger = new CronTriggerFactoryBean();
    trigger.setCronExpression(cron);
    trigger.setJobDetail(job);
    return trigger;
}
 
Example 12
Source File: SlaCheckerCronJob.java    From mojito with Apache License 2.0 5 votes vote down vote up
@Bean
public CronTriggerFactoryBean triggerSlaCheckerCronJob(@Qualifier("slaCheckerCron") JobDetail job) {
    CronTriggerFactoryBean trigger = new CronTriggerFactoryBean();
    trigger.setJobDetail(job);
    trigger.setCronExpression(incidentCheckCron);
    return trigger;
}