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 java.lang.Object
implements ConfigurationProvider

Looks in the classpath for an XML file, "xwork.xml" by default, and uses it for the XWork configuration.

Version:
$Revision: 894090 $
Author:
tmjee, Rainer Hermanns, Neo

Constructor Summary
XmlConfigurationProvider()
           
XmlConfigurationProvider(java.lang.String filename)
           
XmlConfigurationProvider(java.lang.String filename, boolean errorIfMissing)
           
 
Method Summary
protected  void addAction(org.w3c.dom.Element actionElement, PackageConfig.Builder packageContext)
           
protected  PackageConfig addPackage(org.w3c.dom.Element packageElement)
          Create a PackageConfig from an XML element representing it.
protected  void addResultTypes(PackageConfig.Builder packageContext, org.w3c.dom.Element element)
           
protected  java.util.List<ExceptionMappingConfig> buildExceptionMappings(org.w3c.dom.Element element, PackageConfig.Builder packageContext)
          Build a map of ResultConfig objects from below a given XML element.
protected  java.util.List<InterceptorMapping> buildInterceptorList(org.w3c.dom.Element element, PackageConfig.Builder context)
           
protected  PackageConfig.Builder buildPackageContext(org.w3c.dom.Element packageElement)
          This method builds a package context by looking for the parents of this new package.
protected  java.util.Map<java.lang.String,ResultConfig> buildResults(org.w3c.dom.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(java.lang.Object o)
           
protected  java.util.Iterator<java.net.URL> getConfigurationUrls(java.lang.String fileName)
           
 java.util.Map<java.lang.String,java.lang.String> getDtdMappings()
          Returns an unmodifiable map of DTD mappings
protected  java.lang.String guessResultType(java.lang.String type)
           
 int hashCode()
           
 void init(Configuration configuration)
          Initializes with the configuration
protected  void loadDefaultActionRef(PackageConfig.Builder packageContext, org.w3c.dom.Element element)
           
protected  void loadDefaultClassRef(PackageConfig.Builder packageContext, org.w3c.dom.Element element)
           
protected  void loadDefaultInterceptorRef(PackageConfig.Builder packageContext, org.w3c.dom.Element element)
           
protected  void loadExtraConfiguration(org.w3c.dom.Document doc)
          Allows subclasses to load extra information from the document
protected  void loadGlobalResults(PackageConfig.Builder packageContext, org.w3c.dom.Element packageElement)
          Load all of the global results for this package from the XML element.
protected  void loadGobalExceptionMappings(PackageConfig.Builder packageContext, org.w3c.dom.Element packageElement)
          Load all of the global results for this package from the XML element.
protected  void loadInterceptors(PackageConfig.Builder context, org.w3c.dom.Element element)
           
protected  InterceptorStackConfig loadInterceptorStack(org.w3c.dom.Element element, PackageConfig.Builder context)
           
protected  void loadInterceptorStacks(org.w3c.dom.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(java.util.Map<java.lang.String,java.lang.String> mappings)
           
 void setObjectFactory(ObjectFactory objectFactory)
           
 void setThrowExceptionOnDuplicateBeans(boolean val)
           
protected  boolean verifyAction(java.lang.String className, java.lang.String name, Location loc)
           
protected  java.lang.Class verifyResultType(java.lang.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(java.lang.String filename)

XmlConfigurationProvider

public XmlConfigurationProvider(java.lang.String filename,
                                boolean errorIfMissing)
Method Detail

setThrowExceptionOnDuplicateBeans

public void setThrowExceptionOnDuplicateBeans(boolean val)

setDtdMappings

public void setDtdMappings(java.util.Map<java.lang.String,java.lang.String> mappings)

setObjectFactory

public void setObjectFactory(ObjectFactory objectFactory)

getDtdMappings

public java.util.Map<java.lang.String,java.lang.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(java.lang.Object o)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.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(org.w3c.dom.Element actionElement,
                         PackageConfig.Builder packageContext)
                  throws ConfigurationException
Throws:
ConfigurationException

verifyAction

protected boolean verifyAction(java.lang.String className,
                               java.lang.String name,
                               Location loc)

addPackage

protected PackageConfig addPackage(org.w3c.dom.Element packageElement)
                            throws ConfigurationException
Create a PackageConfig from an XML element representing it.

Throws:
ConfigurationException

addResultTypes

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

verifyResultType

protected java.lang.Class verifyResultType(java.lang.String className,
                                           Location loc)

buildInterceptorList

protected java.util.List<InterceptorMapping> buildInterceptorList(org.w3c.dom.Element element,
                                                                  PackageConfig.Builder context)
                                                           throws ConfigurationException
Throws:
ConfigurationException

buildPackageContext

protected PackageConfig.Builder buildPackageContext(org.w3c.dom.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 java.util.Map<java.lang.String,ResultConfig> buildResults(org.w3c.dom.Element element,
                                                                    PackageConfig.Builder packageContext)
Build a map of ResultConfig objects from below a given XML element.


guessResultType

protected java.lang.String guessResultType(java.lang.String type)

buildExceptionMappings

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


loadDefaultInterceptorRef

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

loadDefaultActionRef

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

loadGlobalResults

protected void loadGlobalResults(PackageConfig.Builder packageContext,
                                 org.w3c.dom.Element packageElement)
Load all of the global results for this package from the XML element.


loadDefaultClassRef

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

loadGobalExceptionMappings

protected void loadGobalExceptionMappings(PackageConfig.Builder packageContext,
                                          org.w3c.dom.Element packageElement)
Load all of the global results for this package from the XML element.


loadInterceptorStack

protected InterceptorStackConfig loadInterceptorStack(org.w3c.dom.Element element,
                                                      PackageConfig.Builder context)
                                               throws ConfigurationException
Throws:
ConfigurationException

loadInterceptorStacks

protected void loadInterceptorStacks(org.w3c.dom.Element element,
                                     PackageConfig.Builder context)
                              throws ConfigurationException
Throws:
ConfigurationException

loadInterceptors

protected void loadInterceptors(PackageConfig.Builder context,
                                org.w3c.dom.Element element)
                         throws ConfigurationException
Throws:
ConfigurationException

getConfigurationUrls

protected java.util.Iterator<java.net.URL> getConfigurationUrls(java.lang.String fileName)
                                                         throws java.io.IOException
Throws:
java.io.IOException

loadExtraConfiguration

protected void loadExtraConfiguration(org.w3c.dom.Document doc)
Allows subclasses to load extra information from the document

Parameters:
doc - The configuration document


Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.