spring源码分析1
强烈推介IDEA2020.2破解激活,IntelliJ IDEA 注册码,2020.2 IDEA 激活码
1,学习spring源码笔记
下面是各个类的作用
容器的基础是xmlBeanFactory
XmlBeanFactory bf = new XmlBeanFactory (new ClassPathResource(“beanFactoryTest.xml”))
classPathResource是一个资源统一解析器
@Override
public InputStream getInputStream() throws IOException {
InputStream is;
if (this.clazz != null) {
is = this.clazz.getResourceAsStream(this.path);
}
else if (this.classLoader != null) {
is = this.classLoader.getResourceAsStream(this.path);
}
else {
is = ClassLoader.getSystemResourceAsStream(this.path);
}
if (is == null) {
throw new FileNotFoundException(getDescription() + " cannot be opened because it does not exist");
}
return is;
}
通过classLoader进行加载配置文件资源。
super(parentBeanFactory)调用 AbstractAutowireCapableBeanFactory
/**
* Create a new AbstractAutowireCapableBeanFactory.
*/
public AbstractAutowireCapableBeanFactory() {
super();
ignoreDependencyInterface(BeanNameAware.class);
ignoreDependencyInterface(BeanFactoryAware.class);
ignoreDependencyInterface(BeanClassLoaderAware.class);
}
加载Bean
注册bean
原文链接:https://gper.club/articles/7e7e7f7ff3g58gc2