Bean Life Cycle
by, 07-07-2012 at 06:34 PM (1135 Views)
POJO components are presented by a spring bean which perform certain operations that are considerably useful. All of the SpringBeans which are present in Spring Container are called IOC Container. Spring framework is considered to be very transparent and it hides various infrastructure complexities and communication which occurs b/w spring beans and spring container. Sequence of activities is listed by this section which will be occurring b/w Bean instantiation Bean time and will be handing over the Bean reference towards the application of client.
1. Spring Bean definition is found by the bean container in configuration file.
2. Bean instance is created by the Bean container by the help of Java Reflection API.
3. In case properties are mentioned, they are also applicable. If bean is a property then it could be set and resolved.
4. If the BeanNameAware interface is implemented by Bean class then method thesetBeanName() would be called by passing Bean name.
5. If interface BeanClassLoaderAware is implemented by the Bean class then method setBeanClassLoader() shall be called when ClassLoader object instance is passed which loaded the bean.
6. If BeanFactoryAware interface is implemented by Bean class then method methodsetBeanFactory() shall be called when BeanFactory instance is passed.
7. If some BeanPostProcessors object is present in association with the BeanFactorythat then postProcessBeforeInitialization() method shall be called before the Bean properties are being set.
8. If interface the InitializingBean is implemented by Bean class then method methodafterPropertiesSet() shall be called once all of the properties of Bean that have been defined in the files of configuration are set.