15、生命周期-BeanPostProcessor-后置处理器

  • BeanPostProcessor 接口
package org.springframework.beans.factory.config;

import org.springframework.beans.BeansException;
import org.springframework.lang.Nullable; public interface BeanPostProcessor { // 初始化之前
@Nullable
default Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean;
} // 初始化之后
@Nullable
default Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
return bean;
} }

15.1 编写MyBeanPostProcessor 实现BeanPostProcessor接口

package com.hw.springannotation.beans;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component; /**
* @Description 后置处理器
* @Author Administrator
* @Date 2018/11/28
*/
@Component // 将后置处理器加入到IOC容器中
public class MyBeanPostProcessor implements BeanPostProcessor { /**
* @return 返回之后要用 的 bean
*/
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
System.out.println(" postProcessBeforeInitialization" + beanName + "> " + bean);
return bean;
} public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
System.out.println(" postProcessAfterInitialization" + beanName + "> " + bean);
return bean;
}
}

15.2 测试

最新文章

  1. XCode8向ITunes提交版本,不显示或提示无效的版本
  2. phpcms从表v9_news_data中字段content中用正则取出图片的地址输出
  3. Jeff Dean
  4. 分享一个刷网页PV的python小脚本
  5. css 集锦。
  6. 【Winform】DataTable绑定到ComboBox
  7. Aa3.0 事件机制
  8. APNS IOS 消息推送沙盒模式和发布模式
  9. Python+reuqests自动化接口测试
  10. 转载,matla滤波函数
  11. 利用sqlalchemy读取数据库 和pandas的Dataframe对象 互相生成
  12. Luffy之登录认证以及JWT
  13. 解决Win10家庭版没有‘本地用户和组’问题
  14. Driving proportional valves from microcontroller
  15. Safari不兼容Javascript中的Date问题
  16. BackBone.js之Router
  17. JavaScript 简介--对javascript的初识,最基础的了解
  18. VC 系统托盘编程,含有气泡提示
  19. CentOS6中OpenMP的运行时间或运行性能分析
  20. 在python中配置MySQL数据库

热门文章

  1. opencv实现人脸识别(一)opencv的相关知识了解
  2. eclipse New菜单项的显示问题
  3. scratch少儿编程第一季——05、移动还可以这样动
  4. harbor环境搭建及web使用
  5. Comet OJ - Contest #5 简要题解
  6. django 浅谈索引(转)
  7. C#类型转换工具类
  8. JSON序列化必看以及序列化工具类
  9. zblog2.X 连不上数据库原因
  10. iis 虚拟目录 文件服务器