您的位置:首页 > 编程语言 > Java开发

【Spring】对象后期处理,BeanPostProcessor

2016-07-11 22:34 851 查看
当我们使用Spring容器管理对象时,需要对对象进行一些后期处理时,比如数据处理、数据预加载,可以使用BeanPostProcessor接口。

简单演示它的用法。

定义扫描包,显示定义BeanPostProcessor的实现类:

七月 11, 2016 10:31:13 下午 org.springframework.context.support.ClassPathXmlApplicationContext prepareRefresh
信息: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@427a39ea: startup date [Mon Jul 11 22:31:13 CST 2016]; root of context hierarchy
七月 11, 2016 10:31:13 下午 org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
信息: Loading XML bean definitions from class path resource [spring.xml]
七月 11, 2016 10:31:13 下午 org.springframework.beans.factory.support.DefaultListableBeanFactory preInstantiateSingletons
信息: Pre-instantiating singletons in org.springframework.beans.factory.support.DefaultListableBeanFactory@6371be16: defining beans [userService,org.springframework.context.annotation.internalConfigurationAnnotationProcessor,org.springframework.context.annotation.internalAutowiredAnnotationProcessor,org.springframework.context.annotation.internalRequiredAnnotationProcessor,org.springframework.context.annotation.internalCommonAnnotationProcessor,myBeanPostProcessor,org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor]; root of factory hierarchy
postProcessBeforeInitialization : com.nicchagil.springapplication.No004BeanPostProcessor.UserService
some operation in this point.
postProcessAfterInitialization : com.nicchagil.springapplication.No004BeanPostProcessor.UserService
some operation in this point.
query user method.


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: