1.

Explain Bean life cycle in Spring Bean Factory Container.

Answer»

The Bean life cycle is as FOLLOWS:

  • The IoC CONTAINER instantiates the bean from the bean’s definition in the XML file.
  • Spring then populates all of the properties using the dependency injection as specified in the bean definition.
  • The bean factory container CALLS setBeanName() which take the bean ID and the corresponding bean has to implement BeanNameAware interface.
  • The factory then calls setBeanFactory() by passing an instance of itself (if BeanFactoryAware interface is implemented in the bean).
  • If BeanPostProcessors is associated with a bean, then the preProcessBeforeInitialization() METHODS are invoked.
  • If an init-method is specified, then it will be called.
  • Lastly, postProcessAfterInitialization() methods will be called if there are any BeanPostProcessors associated with the bean that needs to be RUN post creation.


Discussion

No Comment Found