- The Bean container finds the definition of the Spring Bean in the configuration file.
- The Bean container creates an instance of a Bean using the Java Reflection API.
- If some attribute values are involved utilize
set()
Method sets some property values. - If the Bean is implemented
BeanNameAware
Interface, callsetBeanName()
Method, the name of the Bean passed in. - If the Bean is implemented
BeanClassLoaderAware
Interface, callsetBeanClassLoader()
Method, passed inClassLoader
Object. - Similar to the above, if other implementations are implemented
*.Aware
Interface to invoke the corresponding method. - If there is a Spring container associated with loading the Bean
BeanPostProcessor
Object, executepostProcessBeforeInitialization()
methods - If the Bean is implemented
InitializingBean
Interface, executeafterPropertiesSet()
Methods. - If the Bean definition in the configuration file contains the init-method attribute, the specified method is executed.
- If there is a Spring container associated with loading the Bean
BeanPostProcessor
Object, executepostProcessAfterInitialization()
methods - When it is time to destroy the Bean, if the Bean is implemented
DisposableBean
Interface, executedestroy()
Methods. - When it is time to destroy a Bean, execute the specified method if the Bean’s definition in the configuration file contains the destroy-method attribute.