Spring-AOP和IOC调用过程

Posted wu6660563

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Spring-AOP和IOC调用过程相关的知识,希望对你有一定的参考价值。

SpringAOP

SpringAOP大致执行过程

AbstractAutowireCapableBeanFactory

  1. createBean()//->AbstractAutowireCapableBeanFactory#doCreateBean()
  2. doCreateBean()//->AbstractAutowireCapableBeanFactory#initializeBean()
  3. initializeBean()//-AbstractAutowireCapableBeanFactory#applyBeanPostProcessorsAfterInitialization()
  4. applyBeanPostProcessorsAfterInitialization()//->AbstractAutoProxyCreator#postProcessAfterInitialization()

AbstractAutoProxyCreator

  1. postProcessAfterInitialization()//->AbstractAutoProxyCreator#wrapIfNecessary()
  2. wrapIfNecessary()//->AbstractAutoProxyCreator#getAdvicesAndAdvisorsForBean()
    注:由子类AbstractAdvisorAutoProxyCreator实现//->AbstractAutoProxyCreator#createProxy()
    createProxy()//->ProxyFactory#getProxy()

AbstractAutoProxyCreator

  1. getAdvicesAndAdvisorsForBean()//->AbstractAutoProxyCreator#findEligibleAdvisors()
  2. findEligibleAdvisors()//->AbstractAutoProxyCreator#sortAdvisors()
  3. sortAdvisors()//->AnnotationAwareOrderComparator#sort()

AbstractAutoProxyCreator

  1. createProxy()//->ProxyCreatorSupport#getProxy()

ProxyFactory

  1. getProxy()//->ProxyCreatorSupport#createAopProxy()

DefaultAopProxyFactory

  1. createAopProxy()//->返回一个AopProxy对象给AbstractAutoProxyCreator#createProxy()

JdkDynamicAopProxy

  1. invoke()//->AdvisedSupport#getInterceptorsAndDynamicInterceptionAdvice()

SpringIOC

SpringDI大致调用过程

AbstractBeanFactory

  1. getBean() //->AbstractBeanFactory#getBean() //从Bean工厂获取一个实例Bean
  2. doGetBean()//->AbstractBeanFactory#doGetBean(),//返回一个指定Bean的实例,如果没有,则调用createBean

AbstractAutowireCapableBeanFactory

  1. createBean()//->AbstractAutowireCapableBeanFactory#createBean() //创建一个Bean实例,用于doGetBean方法
  2. createBeanInstance()//->AbstractAutowireCapableBeanFactory#createBeanInstance() //使用适当的创建策略为指定的Bean创建实例
  3. instantiateBean()//->AbstractAutowireCapableBeanFactory#instantiateBean() //初始化给定的Bean实例
  4. populateBean()//->AbstractAutowireCapableBeanFactory#populateBean() //对Bean属性依赖注入进行处理
  5. applyPropertyValues()//->AbstractAutowireCapableBeanFactory#applyPropertyValues() //对属性进行注入

BeanDefinitionValueResolver

  1. resolveValueIfNecessary()//->BeanDefinitionValueResolver#resolveValueIfNecessary() //转换属性值

AbstractPropertyAccessor

  1. setPropertyValues()//->AbstractPropertyAccessor#setPropertyValues() //进行我们的属性依赖注入

AbstractNestablePropertyAccessor

  1. processKeyedProperty() or processLocalProperty() //设置本地属性或者Key属性

以上是关于Spring-AOP和IOC调用过程的主要内容,如果未能解决你的问题,请参考以下文章

Spring-AOP切面编程

spring-aop入门案例

spring-aop

怎么配置spring-aop-4.0.xsd

Spring-AOP

Spring-AOP源码分析随手记