The Bean's life cycle in spring

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.