Code Analysis During Struts2 Initialization

Source: Internet
Author: User

According to the web. xml configuration



Call FilterDispatcher. init (FilterConfig filterConfig)

1. Create org. apache. struts2.Dispatcher and call the init () method.

1.1. Create com. opensymphony. xwork2.config. ConfigurationManager. The attribute List <ContainerProvider> containerProviders stores all configurations.

1.2. init_DefaultProperties ();

Initialize defaproperpropertiesprovider. The method register (ContainerBuilder builder, LocatableProperties props) will load settings from org/apache/struts2/default. properties to props, and add it to containerProviders.

1.3. init_TraditionalXmlConfigurations ();

By default, based on struts-default.xml, struts-plugin.xml, struts. xml (you can modify the loading path according to init-param: config) to create three org. apache. struts2.config. strutsXmlConfigurationProvider. By default, the method register will read props from the corresponding configuration file and load it to setting. The bean will be placed in ContainerBuilder, and three containerProviders will be added to containerProviders.

1.4. init_LegacyStrutsProperties ();

Initialize LegacyPropertiesConfigurationProvider and add containerProviders

1.5. init_CustomConfigurationProviders ();

Initialize the class that implements the ContentProvider interface according to init-param: configProviders, and add containerProviders.

1.6. init_FilterInitParameters ();

Initialize a ConfigurationProvider, read the defined initParams from web. xml, and put them in props

1.7. init_AliasStandardObjects ();

Initialize BeanSelectionProvider

1.8. Container container = init_PreloadConfiguration ()

1.8.1. during initialization, configuration. reloadContainer (getContainerProviders () will be executed ());

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

Method: reloadContainer (List <ContainerProvider> providers)

Initialize ContainerProperties props and ContainerBuilder

Traverse containerProviders and call its register (builder, props) Method

Then inject props into the builder.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.