Spring’s Bean lifecycle:

  • The Bean’s BeanDefiniton is being parsed, loaded by Annotation or XML/Properties, parsed and converted to BeanDefiniton.
  • Register BeanDefiniton with BeanFactory’s container. The BeanDefinition of the Bean can then be modified through the BeanFactoyPostProcess.
  • The next step is to Bean instantiation of pre-processing, instantiation, post processing, and then is Aware the callback, is ApplicationContextAwareProcessor processing, mainly EnvironmentAware, EmbeddedValueResolverAw Motorcycle, ResourceLoaderAware, ApplicationEventPublisherAware, MessageSourceAware callback, ApplicationContextAware interface.
  • Bean initialization that is calling BeanPostProcessor postProcessBeforeInitialization method.
  • Call populateBean to populate the property.
  • The callback of Aware interface is mainly BeanNameAware, BeanClassLoaderAware and BeanFactoryAware.
  • Call BeanPostProcess postProcessBeforeInitialization method.
  • Call the afterPropertiesSet method of the InitializingBean.
  • Executes a custom init-method method.
  • Call BeanPostProcess postProcessBeforeInitialization method, return BeanWrapper object.
  • The destruction preprocessing of the destruction bean.
  • The destruction of the bean.
  • Post-processing to destroy beans.

Summary of today’s main Spring bean life cycle of each process combing, subsequent, will be the source of each process analysis.