forked from doocs/source-code-hunter
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
19 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
BeanPostProcessor接口 也叫 Bean后置处理器,作用是在Bean对象实例化和依赖注入完成后,在显示调用bean的init-method(初始化方法)的前后添加我们自己的处理逻辑。注意是Bean实例化完毕后及依赖注入完成后触发的,接口的源码如下。 | ||
|
||
```java | ||
public interface BeanPostProcessor { | ||
/** | ||
* 实例化、依赖注入完毕, | ||
* 在调用显示的初始化之前完成一些定制的初始化任务 | ||
*/ | ||
Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException; | ||
|
||
/** | ||
* 实例化、依赖注入、初始化完毕时执行 | ||
*/ | ||
Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException; | ||
} | ||
``` | ||
|
||
使用方法也很简单,实现 BeanPostProcessor接口,然后将实现类注入IoC容器即可。 |