Spring 5.x Source trip forty-one BeanFactoryPostProcessors extension points
- Figure no less
- BeanDefinitionRegistryPostProcessor
- PriorityOrdered且BeanDefinitionRegistryPostProcessor
- Ordered且BeanDefinitionRegistryPostProcessor
- The remaining BeanDefinitionRegistryPostProcessor
- invokeBeanFactoryPostProcessors
- All BeanFactoryPostProcessor last treatment
- registerBeanPostProcessors注册BeanPostProcessor
Figure no less
When the container calls the initialization invokeBeanFactoryPostProcessors
method BeanDefinitionRegistryPostProcessor
and BeanFactoryPostProcessor
call the method, mainly internal ConfigurationClassPostProcessor
configuration file to do the processing, the articles have talked about earlier, not to say, mainly to some of the places listed can be extended out, For example, we can extend the very beginning.
BeanDefinitionRegistryPostProcessor
Initially it will first call from the extended definition.
For example, I want to register a bean
definition, it will at the very beginning register go:
PriorityOrdered且BeanDefinitionRegistryPostProcessor
Then will come and get execution ordered by priority, including here ConfigurationClassPostProcessor
, will go to parse the configuration file, the container classes we want to register all packaged into a bean
defined register into it. :
Ordered且BeanDefinitionRegistryPostProcessor
A logic, just go heavy, default will not have an internal processor, unless you define a can.
The remaining BeanDefinitionRegistryPostProcessor
Finally, the rest:
invokeBeanFactoryPostProcessors
Then we will go to the beginning of the implementation of customized BeanFactoryPostProcessors
and just registered BeanFactoryPostProcessor
type of processor postProcessBeanFactory
method:
All BeanFactoryPostProcessor last treatment
Later will be BeanFactoryPostProcessor
the type of acquisition, and then to perform, because our custom or some inner class is BeanFactoryPostProcessor
the type of self may be defined from BeanDefinitionRegistryPostProcessor
added to the list, it did not handle the front, we had to deal with back once, also in order of priority of.
Here we are processing processor with plant-related, you can register and operate inside the bean
factory.
registerBeanPostProcessors注册BeanPostProcessor
Here is all the BeanPostProcessor
found, instantiated and registered into the container.
Registration before:
After registration:
two are custom internal default is 6
one.
ApplicationContextAwareProcessor
Before initialization is used to set the property:
ImportAwareBeanPostProcessor
is mainly CGLIB
set to configure the agent class when the beanFactory
property, subject to ImportAware incoming metadata annotation:
CommonAnnotationBeanPostProcessor
and AutowiredAnnotationBeanPostProcessor
is the main job of the properties and methods of injection are:
ApplicationListenerDetector
is the main job of listening registration is, if you bean
are ApplicationListener
the type of words:
BeanPostProcessorChecker
is used to check the number of processors to create the right:
Well, here today, we hope to help study and understand, do not spray the Great God see, understand only their own learning, limited capacity, please excuse.