Spring 5.x Source trip forty getBean extension Processor 4.6
Figure no less
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.
to sum up
Basically getBean
extension 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 spring
over-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.