@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof AsyncConfigurer) { AsyncConfigurer configurer = (AsyncConfigurer) bean; return new TracedAsyncConfigurer(tracer, configurer); } return bean; }
@Test public void should_return_async_configurer_when_bean_instance_of_it() { CustomAsyncConfigurerAutoConfiguration configuration = new CustomAsyncConfigurerAutoConfiguration(); Object bean = configuration .postProcessAfterInitialization(mock(AsyncConfigurer.class), "myAsync"); then(bean).isInstanceOf(TracedAsyncConfigurer.class); }
@Override public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { if (bean instanceof AsyncConfigurer) { AsyncConfigurer configurer = (AsyncConfigurer) bean; return new LazyTraceAsyncCustomizer(this.beanFactory, configurer); } return bean; }
@Test public void should_return_lazy_async_configurer_when_bean_is_async_configurer() throws Exception { AsyncCustomAutoConfiguration configuration = new AsyncCustomAutoConfiguration(); Object bean = configuration .postProcessAfterInitialization(mock(AsyncConfigurer.class), "someName"); then(bean).isInstanceOf(LazyTraceAsyncCustomizer.class); }
public TracedAsyncConfigurer(Tracer tracer, AsyncConfigurer delegate) { this.tracer = tracer; this.delegate = delegate; }
public LazyTraceAsyncCustomizer(BeanFactory beanFactory, AsyncConfigurer delegate) { this.beanFactory = beanFactory; this.delegate = delegate; }