zoukankan      html  css  js  c++  java
  • Struts2初始化过程代码分析

    根据web.xml的配置

    image

    调用FilterDispatcher.init(FilterConfig filterConfig)

    1. 创建org.apache.struts2.Dispatcher,并调用init()方法

    1.1. 创建com.opensymphony.xwork2.config.ConfigurationManager,其中属性List<ContainerProvider> containerProviders存放所有配置。

    1.2. init_DefaultProperties();

    初始化DefaultPropertiesProvider,其中方法register(ContainerBuilder builder, LocatableProperties props)实现会从org/apache/struts2/default.properties加载settings到props中,最后将其加入containerProviders.

    1.3. init_TraditionalXmlConfigurations();

    默认根据struts-default.xml,struts-plugin.xml,struts.xml (可根据init-param:config 修改加载路径) 分别创建三个 org.apache.struts2.config. StrutsXmlConfigurationProvider,其中方法register实现默认会从相应配置文件读取props加载到setting中,会将bean放入ContainerBuilder中,最后将三个containerProviders并加入containerProviders

    1.4. init_LegacyStrutsProperties();

    初始化LegacyPropertiesConfigurationProvider,并加入containerProviders

    1.5. init_CustomConfigurationProviders();

    根据init-param:configProviders初始化实现了ContentProvider接口的类,并加入containerProviders.

    1.6. init_FilterInitParameters() ;

    初始化一个ConfigurationProvider,将定义的initParams从web.xml中读入,放入props

    1.7. init_AliasStandardObjects() ;

    初始化BeanSelectionProvider

    1.8. Container container = init_PreloadConfiguration()

    1.8.1. 在初始化时会去执行configuration.reloadContainer(getContainerProviders());

    类:com.opensymphony.xwork2.config.impl.DefaultConfiguration

    方法:reloadContainer(List<ContainerProvider> providers)

    初始化ContainerProperties props,ContainerBuilder builder

    遍历containerProviders,调用其register(builder, props)方法

    再将props注入builder中。

  • 相关阅读:
    hdu1209(Clock)
    [NodeJS]使用Node.js写一个简单的在线聊天室
    UVa 11168 Airport , 凸包
    【数据结构与算法】(二) c 语言链表的简单操作
    Struts简单介绍
    bzoj3931【CQOI2015】网络吞吐量
    python爬虫解决百度贴吧登陆验证码问题
    TNS-01251: Cannot set trace/log directory under ADR
    Oracle 监听器日志文件过大导致监听异常
    RHEL7
  • 原文地址:https://www.cnblogs.com/jinspire/p/2182240.html
Copyright © 2011-2022 走看看