失效链接处理 |
Spring Bean生命周期 PDF 下载
本站整理下载:
相关截图:
![]()
主要内容:
容器级-影响多个Bean的接口
InstantiationAwareBeanPostProcessor
BeanPostProcessor
实现了这些接口的Bean会切入到多个Bean的生命周期中。正因为如此,这些接口的功能非常强大,
Spring内部扩展也经常使用这些接口,例如自动注入以及AOP的实现都和他们有关。
InstantiationAwareBeanPostProcessor接口
public interface InstantiationAwareBeanPostProcessor extends BeanPostProcessor { Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) throws BeansException; boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException; PropertyValues postProcessPropertyValues( PropertyValues pvs, PropertyDescriptor[] pds, Object bean, String beanName) throws BeansException; }
postProcessBeforeInstantiation Bean实例化之前
postProcessAfterInstantiation Bean 实例化之后
postProcessPropertyValues 处理bean的属性值调用时机为postProcessAfterInstantiation执行之
后并返回true, 返回的PropertyValues将作用于给定bean属性赋值,5.1 之后这个方法过期换成了
postProcessProperties
BeanPostProcessor接口
postProcessBeforeInitialization Bean初始化之前
postProcessAfterInitialization Bean 初始化之后
Bean级-只调用一次的接口
Aware类型的接口
BeanNameAware
BeanClassLoaderAware
BeanFactoryAware
EnvironmentAware
EmbeddedValueResolverAware
ApplicationContextAware是复合接口包含(ResourceLoaderAware,
ApplicationEventPublisherAware, MessageSourceAware)
|