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)