/** * {@inheritDoc} * Reset the value resolver on the inner {@link ScheduledAnnotationBeanPostProcessor} * so that we can parse durations. This is due to how {@link org.springframework.scheduling.annotation.SchedulingConfiguration} * creates the processor and does not provide a way for one to inject a value resolver. */ @Override protected void onRefresh() { final ScheduledAnnotationBeanPostProcessor sch = (ScheduledAnnotationBeanPostProcessor) getBeanFactory().getBean(TaskManagementConfigUtils.SCHEDULED_ANNOTATION_PROCESSOR_BEAN_NAME, BeanPostProcessor.class); sch.setEmbeddedValueResolver(new CasConfigurationEmbeddedValueResolver(this)); super.onRefresh(); }
/** * Gets string value resolver. * * @param applicationContext the application context * @return the string value resolver */ public static StringValueResolver prepScheduledAnnotationBeanPostProcessor(final ApplicationContext applicationContext) { final StringValueResolver resolver = new CasConfigurationEmbeddedValueResolver(applicationContext); final ScheduledAnnotationBeanPostProcessor sch = applicationContext.getBean(ScheduledAnnotationBeanPostProcessor.class); sch.setEmbeddedValueResolver(resolver); return resolver; }
@Test public void shouldRegisterSchedulerPostProcessor() { // when ScheduledAnnotationBeanPostProcessor bean = applicationContext.getBean(ScheduledAnnotationBeanPostProcessor.class); // then assertNotNull(bean); }
@Override public void postProcessBeanFactory(final ConfigurableListableBeanFactory beanFactory) throws BeansException { String schedulingDisabled = myEnvironment.getProperty("scheduling_disabled"); if ("true".equals(schedulingDisabled)) { for (String beanName : beanFactory.getBeanNamesForType(ScheduledAnnotationBeanPostProcessor.class)) { ((DefaultListableBeanFactory) beanFactory).removeBeanDefinition(beanName); } } }
@Bean public ScheduledAnnotationBeanPostProcessor scheduledAnnotationBeanPostProcessor() { return new ScheduledAnnotationBeanPostProcessor(); }