@Test public void testSimpleTaskConfig() { ScheduledTaskRegistrar registrar = new ScheduledTaskRegistrar(); TaskConfiguration config = registrar.getTaskConfiguration(new TestTask()); ScheduledTask annotation = TestTask.class.getAnnotation(ScheduledTask.class); assertEquals(config.getName(), annotation.name()); assertEquals(config.getGroup(), annotation.group()); assertEquals(config.getCron(), annotation.cron()); assertEquals(config.isCluster(), annotation.cluster()); }
TaskConfiguration getTaskConfiguration(Object bean) { TaskConfiguration.Builder builder = TaskConfiguration.builder(); ScheduledTask annotation = bean.getClass().getAnnotation(ScheduledTask.class); if (annotation != null) { builder.withAnnotation(annotation, globalProperties); } else { ScheduledQuartzJob quartzJobAnnotation = bean.getClass().getAnnotation(ScheduledQuartzJob.class); if (quartzJobAnnotation == null) { throw new IllegalArgumentException("Annotation @ScheduledTask missing on bean %s"); } builder.withAnnotation(quartzJobAnnotation, globalProperties); } return builder.build(); }
ScheduledTaskRegistrar implements ApplicationContextAware, InitializingBean, DisposableBean { TaskConfiguration getTaskConfiguration(Object bean) { TaskConfiguration.Builder builder = TaskConfiguration.builder(); ScheduledTask annotation = bean.getClass().getAnnotation(ScheduledTask.class); if (annotation != null) { builder.withAnnotation(annotation, globalProperties); } else { ScheduledQuartzJob quartzJobAnnotation = bean.getClass().getAnnotation(ScheduledQuartzJob.class); if (quartzJobAnnotation == null) { throw new IllegalArgumentException("Annotation @ScheduledTask missing on bean %s"); } builder.withAnnotation(quartzJobAnnotation, globalProperties); } return builder.build(); } }
ScheduledTaskRegistrar implements ApplicationContextAware, InitializingBean, DisposableBean { TaskConfiguration getTaskConfiguration(Object bean) { TaskConfiguration.Builder builder = TaskConfiguration.builder(); ScheduledTask annotation = bean.getClass().getAnnotation(ScheduledTask.class); if (annotation != null) { builder.withAnnotation(annotation, globalProperties); } else { ScheduledQuartzJob quartzJobAnnotation = bean.getClass().getAnnotation(ScheduledQuartzJob.class); if (quartzJobAnnotation == null) { throw new IllegalArgumentException("Annotation @ScheduledTask missing on bean %s"); } builder.withAnnotation(quartzJobAnnotation, globalProperties); } return builder.build(); }  }
ScheduledTaskRegistrar implements ApplicationContextAware, InitializingBean, DisposableBean { TaskConfiguration getTaskConfiguration(Object bean) { TaskConfiguration.Builder builder = TaskConfiguration.builder(); ScheduledTask annotation = bean.getClass().getAnnotation(ScheduledTask.class); if (annotation != null) { builder.withAnnotation(annotation, globalProperties); } else { ScheduledQuartzJob quartzJobAnnotation = bean.getClass().getAnnotation(ScheduledQuartzJob.class); if (quartzJobAnnotation == null) { throw new IllegalArgumentException("Annotation @ScheduledTask missing on bean %s"); } builder.withAnnotation(quartzJobAnnotation, globalProperties); } return builder.build(); }  @Override void afterPropertiesSet(); void registerScheduledTaskAnnotatedBeans(); @Override void destroy(); void setApplicationContext(ApplicationContext applicationContext); void setScheduler(TaskScheduler scheduler); }
ScheduledTaskRegistrar implements ApplicationContextAware, InitializingBean, DisposableBean { TaskConfiguration getTaskConfiguration(Object bean) { TaskConfiguration.Builder builder = TaskConfiguration.builder(); ScheduledTask annotation = bean.getClass().getAnnotation(ScheduledTask.class); if (annotation != null) { builder.withAnnotation(annotation, globalProperties); } else { ScheduledQuartzJob quartzJobAnnotation = bean.getClass().getAnnotation(ScheduledQuartzJob.class); if (quartzJobAnnotation == null) { throw new IllegalArgumentException("Annotation @ScheduledTask missing on bean %s"); } builder.withAnnotation(quartzJobAnnotation, globalProperties); } return builder.build(); }  @Override void afterPropertiesSet(); void registerScheduledTaskAnnotatedBeans(); @Override void destroy(); void setApplicationContext(ApplicationContext applicationContext); void setScheduler(TaskScheduler scheduler);  }