Spring Bean Lifecycle with Executable Code
Lifecycle code example
@Component
public class LifeCycleDemoBean implements
InitializingBean,
DisposableBean,
BeanNameAware,
BeanFactoryAware,
ApplicationContextAware {
public LifeCycleDemoBean() {
System.out.println("## 1. I'm in the LifeCycleBean Constructor");
}
/**
* {@link BeanNameAware}
*/
@Override
public void setBeanName(String name) {
System.out.println("## 2. My Bean Name is: " + name);
}