Tuesday, March 1, 2011

What is the typical Bean life cycle in Spring Bean Factory Container


What is the typical Bean life cycle in Spring Bean Factory Container
Bean life cycle in Spring Bean Factory Container is as follows:
·   The spring container finds the bean’s definition from the XML file and instantiates the bean.
·   Using the dependency injection, spring populates all of the properties as specified in the bean definition.
·   If the bean implements the BeanNameAware interface, the factory calls setBeanName(String name) ,It sets the name of the bean in the bean factory that created this bean.
·   If the bean implements the BeanFactoryAware interface, the factory calls setBeanFactory(BeanFactory beanFactory), passing an instance of itself. Invoked after the population of normal bean properties but before an initialization callback such as InitializingBean.afterPropertiesSet() or a custom init-method.
·   If the bean implements the BeanPostProcessors interface, their postProcessBeforeInitialization(Object bean, String beanname) methods will be called.
·   If an init-method is specified for the bean, it will be called.
·   If the bean implements the BeanPostProcessors interface, their postProcessAfterInitialization (Object bean, String beanname) methods will be called.

1 comment:

  1. Rent to Buy knomn as rental purchase . He is a legally documented rental perchase . Such as room, houses,and many more things etc. this is very useful and helpful blog .

    ReplyDelete