BeanFactoryPostProcessor vs BeanPostProcessor
BeanFactoryPostProcessors affect BeanDefinition objects because they are run right after your configuration is read in.There are no bean instances created yet.
So it can’t do anything to your objects instances yet. For Example the PropertyPlaceholderConfigurer is a BeanFactoryPostProcessor, which looks through the
BeanDefinition objects and replaces any ${property.name} with the actual value of property.name from a Properties file, or System.getProperty() or environment variables.
例如:
PropertyPlaceholderConfigurer
EntityManagerBeanDefinitionRegistrarPostProcessor
BeanPostProcessors affect instances of your objects.
For example here is where Spring AOP decides to create proxies for your beans.
So you declare transactions or AOP Aspect JoinPoints to run code when certain methods are called on your beans.
Well how is Spring going to add that “Code” to your code. It uses proxies. So when you call your business logic method, you want it to start a transaction.
So in the BeanPostProcessing phase, Spring will see that you defined transactions on that method, it will create a Proxy object and wrap it around your actual
bean instance, and it will put the Proxy object into the ApplicationContext/BeanFactory’s HashMap under the beans name.
So now when you call getBean() what you get back isn’t the actual Bean Instance, but the Proxy instead that holds the actual bean Instance.
Without the BeanPostProcessor phase, Spring would not be able to do that.
出处:
BeanFactoryPostProcessor vs BeanPostProcessor
深入Spring Boot:那些注入不了的 Spring 占位符
BeanFactoryPostProcessor vs BeanPostProcessor的更多相关文章
- spring 后置处理器BeanFactoryPostProcessor和BeanPostProcessor的用法和区别
主要区别就是: BeanFactoryPostProcessor可以修改BEAN的配置信息而BeanPostProcessor不能,下面举个例子说明 BEAN类: package com.spring ...
- Spring的BeanFactoryPostProcessor和BeanPostProcessor
转载:http://blog.csdn.net/caihaijiang/article/details/35552859 BeanFactoryPostProcessor和BeanPostProces ...
- Spring点滴十一:Spring中BeanFactoryPostProcessor和BeanPostProcessor区别
Spring中BeanFactoryPostProcessor和BeanPostProcessor都是Spring初始化bean时对外暴露的扩展点.两个接口从名字看起来很相似,但是作用及使用场景却不同 ...
- spring扩展点之一:BeanFactoryPostProcessor和BeanPostProcessor
一.BeanFactoryPostProcessor和BeanPostProcessor的区别 BeanFactoryPostProcessor和BeanPostProcessor都是spring初始 ...
- BeanFactoryPostProcessor和BeanPostProcessor
1. BeanFactoryPostProcessor调用(见AbstractApplicationContext.refresh): >> 创建DefaultListableBeanFa ...
- Spring Boot源码(五):BeanFactoryPostProcessor和BeanPostProcessor
BeanFactoryPostProcessor是spring BeanFactory加载Bean后调用, BeanPostProcessor是Bean初始化前后调用. BeanFactoryPost ...
- Spring 钩子之BeanFactoryPostProcessor和BeanPostProcessor的源码学习,FactoryBean
BeanFactoryPostProcessor 是用于增强BeanFactory的(例如可以增强beanDefination), BeanPostProcessor是用于增强bean的,而Facto ...
- spring BeanPostProcessor
BeanPostProcessor spring使用BeanPostProcessor接口来处理生命周期的回调 BeanPostProcessor接口定义的两个方法,分别在bean的(实例化配置和初始 ...
- 简单比较init-method,afterPropertiesSet和BeanPostProcessor
一.简单介绍 1.init-method方法,初始化bean的时候执行,可以针对某个具体的bean进行配置.init-method需要在applicationContext.xml配置文档中bean的 ...
随机推荐
- Go指南_指针接收者
源地址 https://tour.go-zh.org/methods/4 一.描述 你可以为指针接收者声明方法. 这意味着对于某类型 T,接收者的类型可以用 *T 的文法.(此外,T 不能是像 *in ...
- Eclipse使用心得与技巧
一. 常用快捷键(熟练使用快捷键可以充分提高编程效率,吐血整理...) 1,Alt + ↑上方向键:向上移动选中的代码,你可以把一行或者一段代码直接上移几行 2,Alt + ↓下方向键:向下移动选中的 ...
- 图解CentOS系统启动流程
当我们按下开机键后,系统背后的秘密我们是否了解呢?这里,我带大家探索一下linux系统开机背后的秘密. 1.加电自检 主板在接通电源后,系统首先由POST程序来对内部各个设备进行检查,自检中如 ...
- Angular4学习笔记(一)-环境搭建
下载nodejs 下载地址 在命令行输入:npm -v 如果出现如下画面即安装成功 安装Angular的cli命令行工具 命令:sudo npm install -g @angular/cli 输入n ...
- js操作DOM在父元素中的结尾添加子节点注意
impressionHtml=`<img src=${value} alt=""/>`; document.getElementById("wrapper&q ...
- PHP伪造referer突破网盘禁止外链(附115源码)
新建一个文件file.php.后面的参数就是需要伪造referfer的目标地址吧.如:file.php/http://www.xxx.xxx/xxx.mp3 复制内容到剪贴板 代码: <?$ur ...
- 10.12Django form表单
2018-10-12 15:24:23 From表单参考连接: https://www.cnblogs.com/yuanchenqi/articles/7614921.html 新增了ModelFor ...
- C# 单元测试能过,但Web项目就报错!
第一印象肯定是两个项目中各有不同的地方 背景: 公司项目采用IBatic+Castle实现 排查过程: 1.sqlmap文件是否一至,并且读取位置也要正确 2.dao.config文件要一至,读取位置 ...
- ubuntu16.04编译安装imu_tk
imu_tk代码地址 https://bitbucket.org/alberto_pretto/imu_tk 安装依赖项 sudo apt-get install build-essential cm ...
- [No000012E]WPF(6/7):概念绑定
WPF 的体系结构,标记扩展,依赖属性,逻辑树/可视化树,布局,转换等.今天,我们将讨论 WPF 最重要的一部分——绑定.WPF 带来了优秀的数据绑定方式,可以让我们绑定数据对象,这样每次对象发生更改 ...