关注JEECG发展历程 关注最新动态和版本, 记录JEECG成长点滴 更新日志 - 技术支持 - 招聘英才

JEECG最新版本下载 JEECG智能开发平台 - 显著提高开发效率 常见问题 - 入门视频 - 参与开源团队

商务QQ: 69893005、3102411850 商务热线(5*8小时): 010-64808099 官方邮箱: jeecgos@163.com

查看: 7082|回复: 0

Spring Gossip: BeanFactoryPostProcessor

[复制链接]
发表于 2013-8-30 17:31:47 | 显示全部楼层 |阅读模式
在BeanFactory加载Bean定义档的所有内容,但还没正式产生Bean实例之前,您可以对该BeanFactory进行一些处理,您只要实作 org.springframework.beans.factory.config.BeanFactoryPostProcessor:
package org.springframework.beans.factory.config;public interface BeanFactoryPostProcessor {        public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException;}假设您有一个SomClass实作了BeanFactoryPostProcessor,则您可以在Bean定义档中定义它:
....<beans>        <bean id="beanFactoryModifier" class="onlyfun.caterpillar.SomeClass"/>        <bean id="helloBean" class="onlyfun.caterpillar.HelloBean">                ....        </beans>使用ApplicationContext时,若Bean定义档中有定义实作BeanFactoryPostProcessor的类别,则ApplicationContext会自动应用。

在Spring中有几个BeanFactoryPostProcessor的实作实例,像是org.springframework.beans.factory.config.PropertyPlaceholderConfigurerorg.springframework.beans.factory.config.PropertyOverrideConfigurerorg.springframework.beans.factory.config.CustomEditorConfigurer
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表