Can I keep a reference to an exposed bean inside the @Configuration
class so that I can later on execute operations on that same bean? For example:
@Configuration
class MyBeanConfiguration extends DisposableBean {
private MyBean myBean; // Correct?
@Bean
public MyBean myBean() {
return (this.myBean = MyBeanFactory.newMyBean());
}
@Override
public void destroy() throws Exception {
doSomethingWith(myBean);
}
}
Will I run into any trouble with this approach?