专为注解方式来处理的:
在AnnotationConfigUtils的registerAnnotationConfigProcessors方法注入如下几类:
"org.springframework.context.annotation.internalConfigurationAnnotationProcessor" ->ConfigurationClassPostProcessor
"org.springframework.context.annotation.internalAutowiredAnnotationProcessor" -> AutowiredAnnotationBeanPostProcessor
"org.springframework.context.annotation.internalRequiredAnnotationProcessor" -> RequiredAnnotationBeanPostProcessor
"org.springframework.context.annotation.internalCommonAnnotationProcessor" - > CommonAnnotationBeanPostProcessor
"org.springframework.context.event.internalEventListenerProcessor" -> EventListenerMethodProcessor
"org.springframework.context.event.internalEventListenerFactory" -> DefaultEventListenerFactory
该方法在构建AnnotatedBeanDefinitionReader 和ClassPathBeanDefinitionScanner 执行scan方法时被调用
springBoot:
AnnotationConfigApplicationContext 构造函数中初始化AnnotatedBeanDefinitionReader 和 ClassPathBeanDefinitionScanner
AnnotationConfigWebApplicationContext 在loadBeanDefinitions 方法中 初始化reader、scanner。 该方法在父类AbstractRefreshableApplicationContext调用refreshBeanFactory。源头在AbstractApplicationContext的refresh()方法调用obtainFreshBeanFactory -> refreshBeanFactory.
SpringApplication.run ->SpringApplication. prepareContext -> SpringApplication.load ->BeanDefinitionLoader.load -> source instanceof Package 时 会调用ClassPathBeanDefinitionScanner.scan
XmlWebApplicationContext则是XmlBeanDefinitionReader.