com.opensymphony.xwork2.config.providers

## Class XmlConfigurationProvider

- java.lang.Object
- - com.opensymphony.xwork2.config.providers.XmlConfigurationProvider

- All Implemented Interfaces:
    ConfigurationProvider, ContainerProvider, PackageProvider
  Direct Known Subclasses:
    StrutsXmlConfigurationProvider

      public class XmlConfigurationProvider
      extends Object
      implements ConfigurationProvider

  Looks in the classpath for an XML file, "xwork.xml" by default, and uses it for the XWork configuration.
  Version:
    $Revision$
  Author:
    tmjee, Rainer Hermanns, Neo

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `XmlConfigurationProvider()`
    `XmlConfigurationProvider(String filename)`
    `XmlConfigurationProvider(String filename, boolean errorIfMissing)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `addAction(Element actionElement, PackageConfig.Builder packageContext)`
    `protected PackageConfig` | `addPackage(Element packageElement)` Create a PackageConfig from an XML element representing it.
    `protected void` | `addResultTypes(PackageConfig.Builder packageContext, Element element)`
    `protected Set<String>` | `buildAllowedMethods(Element element, PackageConfig.Builder packageContext)`
    `protected List<ExceptionMappingConfig>` | `buildExceptionMappings(Element element, PackageConfig.Builder packageContext)` Build a list of exception mapping objects from below a given XML element.
    `protected List<InterceptorMapping>` | `buildInterceptorList(Element element, PackageConfig.Builder context)`
    `protected PackageConfig.Builder` | `buildPackageContext(Element packageElement)` This method builds a package context by looking for the parents of this new package.
    `protected Map<String,ResultConfig>` | `buildResults(Element element, PackageConfig.Builder packageContext)` Build a map of ResultConfig objects from below a given XML element.
    `void` | `destroy()` Called before removed from the configuration manager
    `boolean` | `equals(Object o)`
    `protected Iterator<URL>` | `getConfigurationUrls(String fileName)`
    `Map<String,String>` | `getDtdMappings()` Returns an unmodifiable map of DTD mappings
    `protected String` | `guessResultType(String type)`
    `int` | `hashCode()`
    `void` | `init(Configuration configuration)` Initializes with the configuration
    `protected void` | `loadDefaultActionRef(PackageConfig.Builder packageContext, Element element)`
    `protected void` | `loadDefaultClassRef(PackageConfig.Builder packageContext, Element element)`
    `protected void` | `loadDefaultInterceptorRef(PackageConfig.Builder packageContext, Element element)`
    `protected void` | `loadExtraConfiguration(Document doc)` Allows subclasses to load extra information from the document
    `protected void` | `loadGlobalAllowedMethods(PackageConfig.Builder packageContext, Element packageElement)`
    `protected void` | `loadGlobalExceptionMappings(PackageConfig.Builder packageContext, Element packageElement)` Load all of the global results for this package from the XML element.
    `protected void` | `loadGlobalResults(PackageConfig.Builder packageContext, Element packageElement)` Load all of the global results for this package from the XML element.
    `protected void` | `loadInterceptors(PackageConfig.Builder context, Element element)`
    `protected InterceptorStackConfig` | `loadInterceptorStack(Element element, PackageConfig.Builder context)`
    `protected void` | `loadInterceptorStacks(Element element, PackageConfig.Builder context)`
    `void` | `loadPackages()` Loads the packages for the configuration.
    `boolean` | `needsReload()` Tells whether the ConfigurationProvider should reload its configuration.
    `void` | `register(ContainerBuilder containerBuilder, LocatableProperties props)` Registers beans and properties for the Container
    `void` | `setDtdMappings(Map<String,String> mappings)`
    `void` | `setFileManagerFactory(FileManagerFactory fileManagerFactory)`
    `void` | `setObjectFactory(ObjectFactory objectFactory)`
    `void` | `setThrowExceptionOnDuplicateBeans(boolean val)`
    `void` | `setValueSubstitutor(ValueSubstitutor valueSubstitutor)`
    `String` | `toString()`
    `protected boolean` | `verifyAction(String className, String name, Location loc)`
    `protected Class` | `verifyResultType(String className, Location loc)`

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

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

- - ### Constructor Detail

    - #### XmlConfigurationProvider

          public XmlConfigurationProvider()

    - #### XmlConfigurationProvider

          public XmlConfigurationProvider(String filename)

    - #### XmlConfigurationProvider

          public XmlConfigurationProvider(String filename,
                                          boolean errorIfMissing)

  - ### Method Detail

    - #### setThrowExceptionOnDuplicateBeans

          public void setThrowExceptionOnDuplicateBeans(boolean val)

    - #### setDtdMappings

          public void setDtdMappings(Map<String,String> mappings)

    - #### setObjectFactory

          public void setObjectFactory(ObjectFactory objectFactory)

    - #### setFileManagerFactory

          public void setFileManagerFactory(FileManagerFactory fileManagerFactory)

    - #### setValueSubstitutor

          public void setValueSubstitutor(ValueSubstitutor valueSubstitutor)

    - #### getDtdMappings

          public Map<String,String> getDtdMappings()

      Returns an unmodifiable map of DTD mappings
      Returns:
        map of DTD mappings

    - #### init

          public void init(Configuration configuration)

      Description copied from interface: `ContainerProvider`
      Initializes with the configuration
      Specified by:
        `init` in interface `ContainerProvider`
      Specified by:
        `init` in interface `PackageProvider`
      Parameters:
        `configuration` - The configuration

    - #### destroy

          public void destroy()

      Description copied from interface: `ContainerProvider`
      Called before removed from the configuration manager
      Specified by:
        `destroy` in interface `ContainerProvider`

    - #### equals

          public boolean equals(Object o)

      Overrides:
        `equals` in class `Object`

    - #### hashCode

          public int hashCode()

      Overrides:
        `hashCode` in class `Object`

    - #### 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`
      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()
                            throws ConfigurationException

      Description copied from interface: `PackageProvider`
      Loads the packages for the configuration.
      Specified by:
        `loadPackages` in interface `PackageProvider`
      Throws:
        `ConfigurationException` - in case of configuration errors

    - #### needsReload

          public boolean needsReload()

      Tells whether the ConfigurationProvider should reload its configuration. This method should only be called if ConfigurationManager.isReloadingConfigs() is true.
      Specified by:
        `needsReload` in interface `ContainerProvider`
      Specified by:
        `needsReload` in interface `PackageProvider`
      Returns:
        true if the file has been changed since the last time we read it

    - #### addAction

          protected void addAction(Element actionElement,
                                   PackageConfig.Builder packageContext)
                            throws ConfigurationException

      Throws:
        `ConfigurationException`

    - #### verifyAction

          protected boolean verifyAction(String className,
                                         String name,
                                         Location loc)

    - #### addPackage

          protected PackageConfig addPackage(Element packageElement)
                                      throws ConfigurationException

      Create a PackageConfig from an XML element representing it.
      Parameters:
        `packageElement` - the given XML element
      Returns:
        the package config
      Throws:
        `ConfigurationException` - in case of configuration errors

    - #### addResultTypes

          protected void addResultTypes(PackageConfig.Builder packageContext,
                                        Element element)

    - #### verifyResultType

          protected Class verifyResultType(String className,
                                           Location loc)

    - #### buildInterceptorList

          protected List<InterceptorMapping> buildInterceptorList(Element element,
                                                                  PackageConfig.Builder context)
                                                           throws ConfigurationException

      Throws:
        `ConfigurationException`

    - #### buildPackageContext

          protected PackageConfig.Builder buildPackageContext(Element packageElement)

      This method builds a package context by looking for the parents of this new package.

      If no parents are found, it will return a root package.

      Parameters:
        `packageElement` - the package element
      Returns:
        the package config builder

    - #### buildResults

          protected Map<String,ResultConfig> buildResults(Element element,
                                                          PackageConfig.Builder packageContext)

      Build a map of ResultConfig objects from below a given XML element.
      Parameters:
        `element` - the given XML element
        `packageContext` - the package context
      Returns:
        map of result config objects

    - #### guessResultType

          protected String guessResultType(String type)

    - #### buildExceptionMappings

          protected List<ExceptionMappingConfig> buildExceptionMappings(Element element,
                                                                        PackageConfig.Builder packageContext)

      Build a list of exception mapping objects from below a given XML element.
      Parameters:
        `element` - the given XML element
        `packageContext` - the package context
      Returns:
        list of exception mapping config objects

    - #### buildAllowedMethods

          protected Set<String> buildAllowedMethods(Element element,
                                                    PackageConfig.Builder packageContext)

    - #### loadDefaultInterceptorRef

          protected void loadDefaultInterceptorRef(PackageConfig.Builder packageContext,
                                                   Element element)

    - #### loadDefaultActionRef

          protected void loadDefaultActionRef(PackageConfig.Builder packageContext,
                                              Element element)

    - #### loadGlobalResults

          protected void loadGlobalResults(PackageConfig.Builder packageContext,
                                           Element packageElement)

      Load all of the global results for this package from the XML element.
      Parameters:
        `packageContext` - the package context
        `packageElement` - the given XML element

    - #### loadGlobalAllowedMethods

          protected void loadGlobalAllowedMethods(PackageConfig.Builder packageContext,
                                                  Element packageElement)

    - #### loadDefaultClassRef

          protected void loadDefaultClassRef(PackageConfig.Builder packageContext,
                                             Element element)

    - #### loadGlobalExceptionMappings

          protected void loadGlobalExceptionMappings(PackageConfig.Builder packageContext,
                                                     Element packageElement)

      Load all of the global results for this package from the XML element.
      Parameters:
        `packageContext` - the package context
        `packageElement` - the given XML element

    - #### loadInterceptorStack

          protected InterceptorStackConfig loadInterceptorStack(Element element,
                                                                PackageConfig.Builder context)
                                                         throws ConfigurationException

      Throws:
        `ConfigurationException`

    - #### loadInterceptorStacks

          protected void loadInterceptorStacks(Element element,
                                               PackageConfig.Builder context)
                                        throws ConfigurationException

      Throws:
        `ConfigurationException`

    - #### loadInterceptors

          protected void loadInterceptors(PackageConfig.Builder context,
                                          Element element)
                                   throws ConfigurationException

      Throws:
        `ConfigurationException`

    - #### getConfigurationUrls

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

      Throws:
        `IOException`

    - #### loadExtraConfiguration

          protected void loadExtraConfiguration(Document doc)

      Allows subclasses to load extra information from the document
      Parameters:
        `doc` - The configuration document

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`

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