杀死Spring - BeanFactory系列中的AbstractAutowireCapatableBeanFactory

杀死Spring - BeanFactory中的AbstractAutowireCapatableBeanFactory

由前面博客我们知道AbstractAutowireCapableBeanFactory的继承关系如下:
杀死Spring - BeanFactory系列中的AbstractAutowireCapatableBeanFactory

从两个方面域和方法来分析AbstractAutowireCapableBeanFactory

一:域

	//实例化策略
	private InstantiationStrategy instantiationStrategy;
    //是否允许循环依赖
    private boolean allowCircularReferences;
    //是否允许
    private boolean allowRawInjectionDespiteWrapping;
    //忽略的依赖类型
    private final Set ignoredDependencyTypes;
    //忽略的依赖接口
    private final Set ignoredDependencyInterfaces;
    //FactoryBean的实例缓存
    private final Map factoryBeanInstanceCache;
    //过滤的属性描述缓存
    private final Map filteredPropertyDescriptorsCache;

二:方法

2.1:

public void copyConfigurationFrom(ConfigurableBeanFactory otherFactory) {
       	//调用父类(AbstractBeanFactory)的copyConfigurationFrom
        super.copyConfigurationFrom(otherFactory);
        //如果otherFactory是DefaultListableBeanFactory或其子类的实例
        //将otherFactory的allowBeanDefinitionOverriding和allowBeanDefinitionOverriding赋值给this
        if (otherFactory instanceof DefaultListableBeanFactory) {
            DefaultListableBeanFactory otherListableFactory = (DefaultListableBeanFactory)otherFactory;
            this.allowBeanDefinitionOverriding = otherListableFactory.allowBeanDefinitionOverriding;
            this.allowEagerClassLoading = otherListableFactory.allowEagerClassLoading;
        }

    }

2.2:

2.3:

2.4:

2.5:

2.6:

2.7

2.8:

2.9:

上一篇:《Spring 手撸专栏》第 2 章:小试牛刀(让新手能懂),实现一个简单的Bean容器


下一篇:BATJ互联网公司必问知识点:Spring十个面试专题及答案