Java Code Examples for org.springframework.scheduling.quartz.CronTriggerFactoryBean#setName()
The following examples show how to use
org.springframework.scheduling.quartz.CronTriggerFactoryBean#setName() .
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 |
@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: Neutron.java From Milkomeda with MIT License | 5 votes |
/** * cron表达式触发器 * @param triggerName 触发器名称 * @param triggerGroup 触发器所在组 * @param cronExpression cron表达式 * @return CronTrigger * @throws ParseException cron解析异常 */ public static CronTrigger createCronTrigger(String triggerName, String triggerGroup, String cronExpression) throws ParseException { CronTriggerFactoryBean factoryBean = new CronTriggerFactoryBean(); factoryBean.setName(triggerName); factoryBean.setGroup(triggerGroup); factoryBean.setCronExpression(cronExpression); // 由于是手动创建的Bean,需要调用afterPropertiesSet()属性初始化方法 factoryBean.afterPropertiesSet(); return factoryBean.getObject(); }
Example 3
Source File: SchedulerConfig.java From zkdoctor with Apache License 2.0 | 5 votes |
/** * 创建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 4
Source File: QuartzConfigration.java From springBoot-study with Apache License 2.0 | 5 votes |
@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 5
Source File: QuartzConfiguration.java From multiapps-controller with Apache License 2.0 | 5 votes |
@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; }