1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
| BeanPostProcessor - Object postProcessBeforeInitialization(Object bean, String beanName) (初始化前执行的回调) - 一般对字段处理的处理器实现此方法或@PostConstruct 例: @ApolloValue @Value @ConfigurationProperties Validator.class @PostConstruct - Object postProcessAfterInitialization(Object bean, String beanName) (初始化后执行的回调) - 一般对于对象再包装或基于此对象初始化后执行后续行为实现此方法 例: @Scheduled AOP DataSourceInitializerPostProcessor
InitDestroyAnnotationBeanPostProcessor - Object postProcessBeforeInitialization(Object bean, String beanName) (初始化前执行 @PostConstruct)
CommonAnnotationBeanPostProcessor implements InstantiationAwareBeanPostProcessor - PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) (处理 @Resource 字段) - @see CommonAnnotationBeanPostProcessor - @see InjectionMetadata
ScheduledAnnotationBeanPostProcessor - Object postProcessAfterInitialization(Object bean, String beanName) (初始化后执行 @Scheduled 任务)
InstantiationAwareBeanPostProcessor extends BeanPostProcessor - Object postProcessBeforeInstantiation(Class<?> beanClass, String beanName) (实例化前的回调) - 目前只有需要提前实现 aop 的实现 - @see AbstractAutowireCapableBeanFactory
-@see AbstractAutowireCapableBeanFactory - boolean postProcessAfterInstantiation(Object bean, String beanName) (实例化后属性填充前的回调) - 如果返回 false 则说明不需要 spring 处理字段后续等操作 - @see AbstractAutowireCapableBeanFactory
-@see AbstractAutowireCapableBeanFactory - PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) (工厂处理字段前字段处理的回调) - 只有 @Autowired @Value 的字段是通过此种方式注入 - @see AbstractAutowireCapableBeanFactory - PropertyValues postProcessPropertyValues()
CommonAnnotationBeanPostProcessor implements InstantiationAwareBeanPostProcessor - PropertyValues postProcessProperties(PropertyValues pvs, Object bean, String beanName) (处理 @Resource 字段) - @see CommonAnnotationBeanPostProcessor - @see InjectionMetadata
SmartInstantiationAwareBeanPostProcessor extends InstantiationAwareBeanPostProcessor - Class<?> predictBeanType(Class<?> beanClass, String beanName) (预测 bean 的类型) - Constructor<?>[] determineCandidateConstructors(Class<?> beanClass, String beanName) (找出最合适的构造方法) - @see AbstractAutowireCapableBeanFactory -@see - @see AbstractAutowireCapableBeanFactory - Object getEarlyBeanReference(Object bean, String beanName)(返回该 bean 的早期引用, 如果不是 aop 则返回参数的 bean. 如果 aop 才会处理)
AutowiredAnnotationBeanPostProcessor - PropertyValues postProcessProperties (处理 @Autowired @Value 字段. 利用反射) - @see AutowiredFieldElement - @see AutowiredMethodElement
MergedBeanDefinitionPostProcessor extends BeanPostProcessor - void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition, Class<?> beanType, String beanName) (合并 BeanDefination) - @see AbstractAutowireCapableBeanFactory
AutowiredAnnotationBeanPostProcessor implements MergedBeanDefinitionPostProcessor InitDestroyAnnotationBeanPostProcessor implements MergedBeanDefinitionPostProcessor ScheduledAnnotationBeanPostProcessor implements MergedBeanDefinitionPostProcessor
DestructionAwareBeanPostProcessor extends BeanPostProcessor - void postProcessBeforeDestruction (销毁前回调) - @see DisposableBeanAdapter
InitDestroyAnnotationBeanPostProcessor implements DestructionAwareBeanPostProcessor - void postProcessBeforeDestruction (销毁前执行 destroy 方法)
- void postProcessBeforeDestruction (销毁前执行 任务 cancel 方法)
|