What is the typical Bean life cycle in Spring BeanFactory Container ?
What is the typical Bean life cycle in Spring BeanFactory Container ?
Bean life cycle in Spring BeanFactory Container is as follows:
a) The spring container finds the bean’s definition (from the XML file) and instantiates the bean.
b) The bean is populated with all the properties as specified in the bean definition. If a property is reference to another bean, then the other bean will be created and populated, and reference injected into the bean.
c) If the bean implements the BeanNameAware interface, the factory calls setBeanName() passing the bean’s ID.
d) If the bean implements the BeanFactoryAware interface, the factory calls setBeanFactory(), passing an instance of Bean Factory.
e) If there are any BeanPostProcessors associated with the bean, their post- ProcessBeforeInitialization() methods will be called for pre initialization.
f) If an init-method is specified for the bean, it will be called.
g) If there are any BeanPostProcessors associated with the bean, their postProcessAfterInitialization() methods will be called.