com.opensymphony.xwork2.config.providers
Class XmlConfigurationProvider

java.lang.Object
  extended by com.opensymphony.xwork2.config.providers.XmlConfigurationProvider
All Implemented Interfaces:
ConfigurationProvider, ContainerProvider, PackageProvider

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: 1985 $
Author:
tmjee, Rainer Hermanns, Neo

Constructor Summary
XmlConfigurationProvider()
           
XmlConfigurationProvider(String filename)
           
XmlConfigurationProvider(String filename, boolean errorIfMissing)
           
 
Method Summary
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  List<ExceptionMappingConfig> buildExceptionMappings(Element element, PackageConfig.Builder packageContext)
          Build a map of ResultConfig 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 loadGlobalResults(PackageConfig.Builder packageContext, Element packageElement)
          Load all of the global results for this package from the XML element.
protected  void loadGobalExceptionMappings(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 setObjectFactory(ObjectFactory objectFactory)
           
 void setThrowExceptionOnDuplicateBeans(boolean val)
           
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, toString, 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)

getDtdMappings

public Map<String,String> getDtdMappings()
Returns an unmodifiable 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

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.

Throws:
ConfigurationException

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.


buildResults

protected Map<String,ResultConfig> buildResults(Element element,
                                                PackageConfig.Builder packageContext)
Build a map of ResultConfig objects from below a given XML element.


guessResultType

protected String guessResultType(String type)

buildExceptionMappings

protected List<ExceptionMappingConfig> buildExceptionMappings(Element element,
                                                              PackageConfig.Builder packageContext)
Build a map of ResultConfig objects from below a given XML element.


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.


loadDefaultClassRef

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

loadGobalExceptionMappings

protected void loadGobalExceptionMappings(PackageConfig.Builder packageContext,
                                          Element packageElement)
Load all of the global results for this package from the 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


Copyright © 2009 OpenSymphony. All Rights Reserved.