文章目录
- bean 核心类
- beanFactory
- bean definition
- ConfigurableListableBeanFactory
- AbstractRefreshableApplicationContext
- bean creation
- DefaultSingletonBeanRegistry
- AbstractAutowireCapableBeanFactory
- AbstractBeanFactory
- spring使用版本 4.3.14.RELEASE
bean 核心类
beanFactory
最直接的就是源码部分注释:
- factory: hold beanDefinitions
- bean: bean unique name
- registry: a central registry of application components
- bean life cycle
- getBean
bean definition
ConfigurableListableBeanFactory
```java BeanDefinition getBeanDefinition(String beanName) throws NoSuchBeanDefinitionException; ```
AbstractRefreshableApplicationContext
- loadBeanDefinitions
bean creation
- BeanCurrentlyInCreationException
- AbstractAutowireCapableBeanFactory extends DefaultSingletonBeanRegistry
DefaultSingletonBeanRegistry
- doCreateBean 大体流程:
- // Instantiate the bean.
- // Allow post-processors to modify the merged bean definition.
- // Eagerly cache singletons to be able to resolve circular references even when triggered by lifecycle interfaces like BeanFactoryAware.
- // Initialize the bean instance.
- // Register bean as disposable.
AbstractAutowireCapableBeanFactory
protected Object createBean
AbstractBeanFactory
protected <T> T doGetBean