020. Spring Bean Life Cycle - dkkahm/study-springfamework5 GitHub Wiki
Starting Up
- Instantiate
- Populate Properties
- Call setBeanName of BeanNameAware
- Call setBeanFactory of BeanFactoryAware
- Call setApplicationContext of ApplicationContextAware
- Preinitialization (Bean PostProcessors)
- afterPropertiesSet of Initializing Beans
- Custom Init Method
- Post Initialization (BeanPostProcessors)
- Bean Ready to Use
Shutting Down
- Container Shutdown
- Disposable Bean's destroy()
- Call Custom Destroy Method
- Terminated
Callback Interfaces
- IntializaingBean.afterPropertiesSet()
- DisposableBean.destroy()
Life Cycle Annotations
- @PostConstructor
- after the bean has bean constructed, but before its retunred to the requesting object
- @PreDestroy
Bean Post Processors
- Implement interface BeanPostProcessor
Aware Interfaces
- ApplicationContextAware
- ApplicationEventPublisherAware
- BeanClassLoaderAware
- BeanFactoryAware
- BeanNameAware
- BootstrapContextAware
- LoadTimeWeaverAware
- MessageSourceAware
- NotificationPublisherAware
- PortletConfigAware
- PortletContextAware
- ResourceLoaderAware
- ServletConfigAware
- ServletContextAware
LifeCycleDemoBean
@Component
public class LifeCycleDemoBean implements InitializingBean, DisposableBean, BeanNameAware, BeanFactoryAware, ApplicationContextAware {
@Override
....
@PostConstruct
....
@PreDestroy
....