When Spring is mentioned, the first thing that comes to mind is IOC. Let’s talk about the understanding of Spring IOC first.

General direction:

1. Inversion of control for Spring managed objects. Before Spring, we controlled objects ourselves. With Spring, you hand over the entire object to Spring control.

DI injects the corresponding property values into the corresponding objects. With an annotation, @AutoWired, populateBean completes the injection.

3. String container stores objects, using map structure, general three-level cache, singletonObjects stores complete Bean objects. The process from Bean creation to Bean destruction is done by the container. The container manages the entire life cycle of beans.

Origin details:

1, is critical in the IOC container, the container is the creation of the process, applied the beanFactory (interface, no concrete implementation), DefaultListableBeanFactory, BeanPostProcessor set some parameters to the bean factory, Properties such as subclasses of the Aware interface.

Load the parse Bean and create beanDefintion for the Bean object (parsing of XML or annotations)

The processing of 3, Spring beanFactoryPostProcessor, Spring there are a lot of extension method, PlaceHolderConfigurSuppor, ConfigrurationClassPostProcessor

4. The BeanDefintion object is instantiated into a concrete bean object by reflection.

5. Bean object initialization process (fill property – call aware subclass, call BeanPostProcessor preprocessing method, drop init-method method, call BeanPostProcessor postprocessing method)

6. Generate the Bean and get it from getBean.

7, destroy,

study hard and make progress every day