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的 ...
随机推荐
- shell-整理目录下的备份文件并生成压缩包
背景: CI构建下来的备份应用包在服务器上保留几十个,空间占用大,看着不好看,可能还用不着,所以准备正好练练手吧! 其实CI上可以设置少保留几个,但是我没管.我只是想练练脚本 先来看一下我的服务器源目 ...
- (实用)pip源
Pypi官方源网站的连接速度实在慢点出奇,可以更换为豆瓣的源 vim ~/.pip/pip.conf 添加如下内容即可: [global]index-url=http://pypi.doubam.co ...
- for循环 while循环 break跳出循环 continue结束本次循环 exit退出整个脚本
- highCharts图表入门简介
一.Highcharts简介 Highcharts:功能强大.开源.美观.图表丰富.兼容绝大多数浏览器的纯js图表库 Highcharts是一款纯javascript编写的图表库,能够很简单便捷的在W ...
- [JS] ECMAScript 6 - String, Number, Function : compare with c#
字符串的扩展 正则的扩展 数值的扩展 函数的扩展 字符串的扩展 js 字符的 Unicode 表示法 codePointAt() String.fromCodePoint() 字符串的遍历器接口 at ...
- fs项目---->async/await的学习(一)
2018-07-11号,我来到了fs项目组担任后端开发的角色.这是我来thoughtworks以来首个的正式项目,不管是在技术还是在敏捷的实践中都是受益匪浅.来感受tw特殊的文化的同时,我希望自己能够 ...
- 【本周主题】第三期 - JavaScript 内存机制
- Hbase学习之windows单机版搭建
1. 下载hadoop-common-2.2.0-bin-master hbase-1.0.2 并解压 2. 配置 修改 三个个环境变量 2.1 JAVA_HOME(如果没有配置请先配置 确保电 ...
- [转]CDN(内容分发网络)技术原理
1. 前言 Internet的高速发展,给人们的工作和生活带来了极大的便利,对Internet的服务品质和访问速度要求越来越高,虽然带宽不断增加, 用户数量也在不断增加,受Web服务器的负荷和传输距离 ...
- thinkphp5---使用自定义助手函数
在进行项目开发的时候,系统自带的助手函数往往满足不了自己的需求,就需要通过自定义助手函数来实现某个功能,具体做法: 新建:myhelper.php 写入: <?php if (!function ...