As the most popular and powerful lightweight framework in Java, Spring is warmly welcomed by programmers. It is necessary to have an accurate understanding of the spring Bean's life cycle. We usually use ApplicationContext as the spring container. Here, we are talking about the life cycle of the bean in ApplicationContext. In fact, Beanfactory is similar, but the processor needs to be manually registered.
first, life cycle flowchart:
The full life cycle of the spring bean starts with the creation of the spring container until the final spring container destroys the bean, which contains a series of key points.
II. Classification of various interface methods
The full life cycle of the bean undergoes various method invocations, which can be divided into the following categories:
1, Bean's own method: This includes the method called by the bean itself and the method specified by the <bean> Init-method and Destroy-method in the configuration file
2. Bean-level life-Cycle interface method: This includes Beannameaware, Beanfactoryaware, Initializingbean, and Diposablebean these interface methods
3, container-level life-Cycle interface method: This includes the Instantiationawarebeanpostprocessor and Beanpostprocessor two interface implementations, generally called their implementation class is "post processor."
4, the factory after the processor interface method: This includes Aspectjweavingenabler, Configurationclasspostprocessor, customautowireconfigurer and so very useful after the factory processor The method of the interface. The factory post processors are also container-level. Called immediately after the context assembly configuration file is applied.
Original link: http://www.cnblogs.com/zrtqsk/p/3735273.html
The Bean's life cycle in spring