如何定位资源,解析资源?
1、进入DefaultListableBeanFactory类,
里面有一个成员变量beanDefinitionMap,Bean定义对象的Map, BeanDefinition就对应XML的属性配置
/** Map of bean definition objects, keyed by bean name */ private final Map<String, BeanDefinition> beanDefinitionMap = new ConcurrentHashMap<String, BeanDefinition>();
上一篇讲到IOC的实现
ClassPathResource resource = new ClassPathSource("beans.xml");
DefaultListableBeanFactory factory = new DefaultListableBeanFactory();
XmlBeanDefinitionReader reader = new XmlBeanDefinitionReader(factory);
reader.loadBeanDefinitions(resource);
首先进入ClassPathResource,进入构造函数
进入第二个构造函数
Assert翻译为中文为“断言”, 就是断定某一个实际的值就是自己预期想要得到的,如果不一样就抛出异常。
Assert.notNull(path, "Path must not be null");
如果path为空,就抛出异常