org.apache.struts2.config

## Class StrutsXmlConfigurationProvider

- java.lang.Object
- - com.opensymphony.xwork2.config.providers.XmlDocConfigurationProvider
  - - com.opensymphony.xwork2.config.providers.XmlConfigurationProvider
    - - org.apache.struts2.config.StrutsXmlConfigurationProvider

- All Implemented Interfaces:
    ConfigurationProvider, ContainerProvider, PackageProvider

      public class StrutsXmlConfigurationProvider
      extends XmlConfigurationProvider

  Override Xwork class so we can use an arbitrary config file

- - ### Field Summary

    - ### Fields inherited from class com.opensymphony.xwork2.config.providers.XmlConfigurationProvider

      `fileManager`

    - ### Fields inherited from class com.opensymphony.xwork2.config.providers.XmlDocConfigurationProvider

      `allowlistClasses, configuration, declaredPackages, documents, dtdMappings, objectFactory, providerAllowlist, throwExceptionOnDuplicateBeans, valueSubstitutor`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StrutsXmlConfigurationProvider()` Constructs the Struts configuration provider using the default struts.xml and no ServletContext
    `StrutsXmlConfigurationProvider(boolean errorIfMissing)` Deprecated.
    `StrutsXmlConfigurationProvider(String filename)` Constructs the configuration provider based on the provided config file
    `StrutsXmlConfigurationProvider(String filename, boolean errorIfMissing, javax.servlet.ServletContext ctx)` Deprecated. since 6.2.0, use `StrutsXmlConfigurationProvider(String, ServletContext)`
    `StrutsXmlConfigurationProvider(String filename, javax.servlet.ServletContext ctx)` Constructs the Struts configuration provider

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected URL` | `findInFileSystem(String fileName)`
    `protected Iterator<URL>` | `getConfigurationUrls(String fileName)` Look for the configuration file on the classpath and in the file system
    `void` | `loadPackages()` Loads the packages for the configuration.
    `boolean` | `needsReload()` Overrides needs reload to ensure it is only checked once per request
    `void` | `register(ContainerBuilder containerBuilder, LocatableProperties props)` Registers beans and properties for the Container
    `String` | `toString()`

    - ### Methods inherited from class com.opensymphony.xwork2.config.providers.XmlConfigurationProvider

      `equals, getDocs, getFinalDocs, getURLs, hashCode, init, loadConfigurationFiles, parseFile, setFileManagerFactory`

    - ### Methods inherited from class com.opensymphony.xwork2.config.providers.XmlDocConfigurationProvider

      `addAction, addAllowedMethodsToSet, addPackage, addResultTypes, allowAndLoadClass, buildActionConfig, buildAllowedMethods, buildExceptionMappings, buildExceptionMappings, buildInterceptorConfig, buildInterceptorList, buildPackageContext, buildResultConfig, buildResultParams, buildResults, buildResultTypeConfig, destroy, getDtdMappings, guessResultType, iterateChildren, iterateChildrenByTagName, iterateElementChildren, iterateElementChildren, loadClass, loadDefaultActionRef, loadDefaultClassRef, loadDefaultInterceptorRef, loadExtraConfiguration, loadGlobalAllowedMethods, loadGlobalExceptionMappings, loadGlobalResults, loadInterceptors, loadInterceptorStack, loadInterceptorStacks, lookupInterceptorReference, registerBean, registerBeanSelection, registerConstant, registerUnknownHandlerStack, setDtdMappings, setObjectFactory, setProviderAllowlist, setThrowExceptionOnDuplicateBeans, setValueSubstitutor, verifyAction, verifyAction, verifyInterceptor, verifyResultType`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### StrutsXmlConfigurationProvider

          public StrutsXmlConfigurationProvider()

      Constructs the Struts configuration provider using the default struts.xml and no ServletContext

    - #### StrutsXmlConfigurationProvider

          @Deprecated
          public StrutsXmlConfigurationProvider(boolean errorIfMissing)

      Deprecated.
      Constructs the configuration provider
      Parameters:
        `errorIfMissing` - If we should throw an exception if the file can't be found

    - #### StrutsXmlConfigurationProvider

          public StrutsXmlConfigurationProvider(String filename)

      Constructs the configuration provider based on the provided config file
      Parameters:
        `filename` - file with Struts configuration

    - #### StrutsXmlConfigurationProvider

          public StrutsXmlConfigurationProvider(String filename,
                                                javax.servlet.ServletContext ctx)

      Constructs the Struts configuration provider
      Parameters:
        `filename` - The filename to look for
        `ctx` - Our ServletContext

    - #### StrutsXmlConfigurationProvider

          @Deprecated
          public StrutsXmlConfigurationProvider(String filename,
                                                            @Deprecated
                                                            boolean errorIfMissing,
                                                            javax.servlet.ServletContext ctx)

      Deprecated. since 6.2.0, use `StrutsXmlConfigurationProvider(String, ServletContext)`

  - ### Method Detail

    - #### register

          public void register(ContainerBuilder containerBuilder,
                               LocatableProperties props)
                        throws ConfigurationException

      Description copied from interface: `ContainerProvider`
      Registers beans and properties for the Container
      Specified by:
        `register` in interface `ContainerProvider`
      Overrides:
        `register` in class `XmlConfigurationProvider`
      Parameters:
        `containerBuilder` - The builder to register beans with
        `props` - The properties to register constants with
      Throws:
        `ConfigurationException` - If anything goes wrong

    - #### loadPackages

          public void loadPackages()

      Description copied from interface: `PackageProvider`
      Loads the packages for the configuration.
      Specified by:
        `loadPackages` in interface `PackageProvider`
      Overrides:
        `loadPackages` in class `XmlConfigurationProvider`

    - #### getConfigurationUrls

          protected Iterator<URL> getConfigurationUrls(String fileName)
                                                throws IOException

      Look for the configuration file on the classpath and in the file system
      Overrides:
        `getConfigurationUrls` in class `XmlConfigurationProvider`
      Parameters:
        `fileName` - The file name to retrieve
      Throws:
        `IOException`
      See Also:
        `XmlConfigurationProvider.getConfigurationUrls(java.lang.String)`

    - #### findInFileSystem

          protected URL findInFileSystem(String fileName)
                                  throws IOException

      Throws:
        `IOException`

    - #### needsReload

          public boolean needsReload()

      Overrides needs reload to ensure it is only checked once per request
      Specified by:
        `needsReload` in interface `ContainerProvider`
      Specified by:
        `needsReload` in interface `PackageProvider`
      Overrides:
        `needsReload` in class `XmlConfigurationProvider`
      Returns:
        true if the file has been changed since the last time we read it

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `XmlConfigurationProvider`

Copyright © 2000–2025 Apache Software Foundation. All rights reserved.