Spring 5.x Source trip forty getBean extension Processor 4.6

Figure no less

Here Insert Picture Description

registerDisposableBeanIfNecessary registered destroy callbacks

I have talked about this earlier, you can refer to the next, and this article .
There are N ways to extend callback methods registered vessel destroyed, when the destruction of the release of resources ah, do some processing ah.

SmartInitializingSingleton的afterSingletonsInstantiated

This is all the singleton instance of the last calls, give notice.
Here Insert Picture Description

to sum up

Basically getBeanextension main point is these interfaces:

  • InstantiationAwareBeanPostProcessor
  • SmartInstantiationAwareBeanPostProcessor
  • BeanPostProcessor
  • MergedBeanDefinitionPostProcessor
  • InitializingBean
  • DisposableBean
  • Supplier

But to a very wide ranging, from a previous instantiation, after instantiation, before injection, injection in pre-initialization, initialization, after initialization, before the destruction of the basic whole life cycle contains. These methods are in fact enough to make you at all stages of the parameters, you can achieve a certain decoupling, connected by a processor and spring, to avoid with springover-coupling.

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.

Published 235 original articles · won praise 74 · views 30000 +

Guess you like

Origin blog.csdn.net/wangwei19871103/article/details/105176080