Spring源码学习-ApplicationContext

2022-11-29 21:41:52 浏览数 (1)

1 ApplicationContext都是什么(它继承了哪些接口)?

2 ApplicationContext有哪些实现子类?

1. 有哪些实现子类?

2. 实现子类可以分为哪几类?

3. 继承体系是怎样的?用了什么设计模式?

3 ApplicationContext中持有什么样的BeanFactory实现?

1. ApplicationContext中持有什么样的BeanFactory实现?

代码语言:javascript复制
private final DefaultListableBeanFactory beanFactory;

2. 它继承、实现了哪些接口、类?

3. BeanFactory的继承体系是怎样的?

4.

4 ApplicationContext的实现子类中加载bean定义的代码结构是怎样的?

xml方式的类结构是怎样的?

application.xml

代码语言:javascript复制
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
                xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                xmlns:context="http://www.springframework.org/schema/context"
                xmlns:aop="http://www.springframework.org/schema/aop"
                xsi:schemaLocation="http://www.springframework.org/schema/beans
                                http://www.springframework.org/schema/beans/spring-beans.xsd
                                http://www.springframework.org/schema/context
                                http://www.springframework.org/schema/context/spring-context.xsd
                                http://www.springframework.org/schema/aop
                                http://www.springframework.org/schema/aop/spring-aop.xsd">
                                
                <bean id="beanE" class="com.study.spring.sample.config.BeanE" />
                <bean id="beanF" class="com.study.spring.sample.config.BeanF" ></bean>
                <context:annotation-config/>
                <context:component-scan base-package="com.study.spring.sample.config" >
                </context:component-scan>
</beans>

XMLConfigMain.java

代码语言:javascript复制
public class XMLConfigMain {
        public static void main(String[] args) {
                ApplicationContext context = new GenericXmlApplicationContext("classpath:com/study/spring/sample/config/application.xml");
                BeanF bf = context.getBean(BeanF.class);
                bf.do1();
        }
}

怎么去看xml解析、注册bean的代码?

过程:

解析xml 注册bean定义---> beanFactory

0 人点赞