Spring-AOP和IOC调用过程
Posted wu6660563
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring-AOP和IOC调用过程相关的知识,希望对你有一定的参考价值。
SpringAOP
SpringAOP大致执行过程
AbstractAutowireCapableBeanFactory
- createBean()//->AbstractAutowireCapableBeanFactory#doCreateBean()
- doCreateBean()//->AbstractAutowireCapableBeanFactory#initializeBean()
- initializeBean()//-AbstractAutowireCapableBeanFactory#applyBeanPostProcessorsAfterInitialization()
- applyBeanPostProcessorsAfterInitialization()//->AbstractAutoProxyCreator#postProcessAfterInitialization()
AbstractAutoProxyCreator
- postProcessAfterInitialization()//->AbstractAutoProxyCreator#wrapIfNecessary()
- wrapIfNecessary()//->AbstractAutoProxyCreator#getAdvicesAndAdvisorsForBean()
注:由子类AbstractAdvisorAutoProxyCreator实现//->AbstractAutoProxyCreator#createProxy()
createProxy()//->ProxyFactory#getProxy()
AbstractAutoProxyCreator
- getAdvicesAndAdvisorsForBean()//->AbstractAutoProxyCreator#findEligibleAdvisors()
- findEligibleAdvisors()//->AbstractAutoProxyCreator#sortAdvisors()
- sortAdvisors()//->AnnotationAwareOrderComparator#sort()
AbstractAutoProxyCreator
- createProxy()//->ProxyCreatorSupport#getProxy()
ProxyFactory
- getProxy()//->ProxyCreatorSupport#createAopProxy()
DefaultAopProxyFactory
- createAopProxy()//->返回一个AopProxy对象给AbstractAutoProxyCreator#createProxy()
JdkDynamicAopProxy
- invoke()//->AdvisedSupport#getInterceptorsAndDynamicInterceptionAdvice()
SpringIOC
SpringDI大致调用过程
AbstractBeanFactory
- getBean() //->AbstractBeanFactory#getBean() //从Bean工厂获取一个实例Bean
- doGetBean()//->AbstractBeanFactory#doGetBean(),//返回一个指定Bean的实例,如果没有,则调用createBean
AbstractAutowireCapableBeanFactory
- createBean()//->AbstractAutowireCapableBeanFactory#createBean() //创建一个Bean实例,用于doGetBean方法
- createBeanInstance()//->AbstractAutowireCapableBeanFactory#createBeanInstance() //使用适当的创建策略为指定的Bean创建实例
- instantiateBean()//->AbstractAutowireCapableBeanFactory#instantiateBean() //初始化给定的Bean实例
- populateBean()//->AbstractAutowireCapableBeanFactory#populateBean() //对Bean属性依赖注入进行处理
- applyPropertyValues()//->AbstractAutowireCapableBeanFactory#applyPropertyValues() //对属性进行注入
BeanDefinitionValueResolver
- resolveValueIfNecessary()//->BeanDefinitionValueResolver#resolveValueIfNecessary() //转换属性值
AbstractPropertyAccessor
- setPropertyValues()//->AbstractPropertyAccessor#setPropertyValues() //进行我们的属性依赖注入
AbstractNestablePropertyAccessor
- processKeyedProperty() or processLocalProperty() //设置本地属性或者Key属性
以上是关于Spring-AOP和IOC调用过程的主要内容,如果未能解决你的问题,请参考以下文章