当前位置:网站首页>When was the autowiredannotationbeanpostprocessor instantiated?
When was the autowiredannotationbeanpostprocessor instantiated?
2022-06-26 05:25:00 【Light dust ×】
AutowiredAnnotationBeanPostProcessor yes spring The cornerstone of automatic assembly , According to the foregoing 《 internalAutowiredAnnotationProcessor Where did it come from ?》, We already know that AutowiredAnnotationBeanPostProcessor When was it added BeanDefinition, In which step is it instantiated ?
Set the breakpoint at refresh() Methodical invokeBeanFactoryPostProcessors It's about

We can see invokeBeanFactoryPostProcessor Note on
/**
* Instantiate and invoke all registered BeanFactoryPostProcessor beans,
* respecting explicit order if given.
* <p>Must be called before singleton instantiation.
*/
I have just passed CET-4 : Instantiate and call all registered BeanFactoryPostProcessor, If the order is given , Come in order ~

Will there be instantiation here AutowiredAnnotationBeanPostProcessor Well ?
You can see , When the program runs ,beaDefinitionNames It contains org.springframework.context.annotation.internalAutowiredAnnotationProcessor Of

And the storage completes instantiation bean Of singletonObects There is no , in other words , up to now ,AutowiredAnnotationBeanPostProcessor Not yet instantiated

next step , perform invokeBeanFactoryPostProcessor, Look again singletonObects, You can see , It only includes ConfigurationClassPostProcessor、DefaultEventListenerFactory and EventListenerMethodProcessor Instantiate the object

What we care about AutowiredAnnotationBeanPostProcessor There is no instantiation , I think this is because it belongs to BeanPostProcessor This system , It doesn't belong to BeanFactoryPostProcessor System reasons

Carry on registerBeanPostProcessors(beanFactory), You can see it at the end ,AutowiredAnnotationBeanPostProcessor Instantiation is complete .

So you can locate ,AutowiredAnnotationBeanPostProcessor The instantiation of occurs in registerBeanPostProcessors(beanFactory) Inside
Follow in , The comments on the methods all look the same , The reality is totally different , about invokeBeanFactoryPostProcessor Is to instantiate and execute , And here is : Instantiate and register all BeanPostProcessor, in other words , The call doesn't happen here .
/**
* Instantiate and register all BeanPostProcessor beans,
* respecting explicit order if given.
* <p>Must be called before any instantiation of application beans.
*/
protected void registerBeanPostProcessors(ConfigurableListableBeanFactory beanFactory) {
PostProcessorRegistrationDelegate.registerBeanPostProcessors(beanFactory, this);
}
Why? ?
My understanding is that BeanFactoryPostProcessor The object of enhancement is BeanFactory, I.e. container , They need to be executed before and after the container creation process , Because the user-defined object will be created soon , Which is execution finishBeanFactoryInitialization(beanFactory), It will be too late to delay , and BeanPostProcessor The object of enhancement is bean object , It should be around bean Before the creation of 、 In the create 、 Create and then execute , To enhance bean The effect of , So here is just instantiation and registration , It's not implemented .
The process of instantiation is also the same as that of ordinary bean object , It's also getBean/doGetBean/createBean/doCreate/createBeanInstance That set , This will be analyzed in a separate context .

边栏推荐
- 使用Jedis监听Redis Stream 实现消息队列功能
- Protocol selection of mobile IM system: UDP or TCP?
- cartographer_fast_correlative_scan_matcher_2d分支定界粗匹配
- A beginner's entry is enough: develop mobile IM from zero
- 递归遍历目录结构和树状展现
- Sentimentin tensorflow_ analysis_ cell
- cartographer_local_trajectory_builder_2d
- The wechat team disclosed that the wechat interface is stuck with a super bug "15..." The context of
- Two step processing of string regular matching to get JSON list
- [unity3d] human computer interaction input
猜你喜欢

Leetcode114. 二叉树展开为链表

关于支付接口回调地址参数字段是“notify_url”,签名过后的特殊字符url编码以后再解码后出现错误(¬ , ¢, ¤, £)

Create SSH key pair configuration steps

cartographer_optimization_problem_2d

Learn cache lines and pseudo sharing of JVM slowly

Learn from small samples and run to the sea of stars

Mongodb image configuration method
Technical past: tcp/ip protocol that has changed the world (precious pictures, caution for mobile phones)

递归遍历目录结构和树状展现

How to select the data transmission format of instant messaging application
随机推荐
Gd32f3x0 official PWM drive has a small positive bandwidth (inaccurate timing)
[unity3d] collider assembly
【MYSQL】MySQL 百万级数据量分页查询方法及其优化
CMakeLists. txt Template
Serious hazard warning! Log4j execution vulnerability is exposed!
Introduction to GUI programming to game practice (I)
Two step processing of string regular matching to get JSON list
The difference between get and post in small interview questions
Mise en file d'attente des messages en utilisant jedis Listening redis stream
Sofa weekly | open source person - Yu Yu, QA this week, contributor this week
Why does the mobile IM based on TCP still need to keep the heartbeat alive?
RESNET practice in tensorflow
Experience of reading the road to wealth and freedom
How to ensure the efficiency and real-time of pushing large-scale group messages in mobile IM?
Installation and deployment of alluxio
Leetcode114. 二叉树展开为链表
【ARM】讯为rk3568开发板buildroot添加桌面应用
[greedy college] Figure neural network advanced training camp
cartographer_optimization_problem_2d
Introduction to GUI programming to game practice (II)