spring初始化流程

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/y41992910/article/details/89818536

spring初始化流程

1.org.springframework.web.context.ContextLoaderListener初始化监听器

事件监听器的初始化方法
@Override
public void contextInitialized(ServletContextEvent event) {
initWebApplicationContext(event.getServletContext());
}
2.调用下面的方法,初始化WebApplicationContext
WebApplicationContext org.springframework.web.context.ContextLoader.initWebApplicationContext(ServletContext servletContext)

初始化完成之后,将对应的ApplicationContext放入到 ServletContext中.方便获取.
String ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE = WebApplicationContext.class.getName() + “.ROOT”;
servletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, this.context);

顶层接口,定义了应用的统一上下文:
org.springframework.context.ApplicationContext
public interface ApplicationContext extends EnvironmentCapable, ListableBeanFactory, HierarchicalBeanFactory,
MessageSource, ApplicationEventPublisher, ResourcePatternResolver
第二级接口
org.springframework.context.ConfigurableApplicationContext
org.springframework.web.context.WebApplicationContext
第三级接口
ConfigurableWebApplicationContext
AbstractRefreshableWebApplicationContext
XmlWebApplicationContext

猜你喜欢

转载自blog.csdn.net/y41992910/article/details/89818536