com.opensymphony.xwork2.config.providers
Class XmlConfigurationProvider

java.lang.Object
  extended by com.opensymphony.xwork2.config.providers.XmlConfigurationProvider
All Implemented Interfaces:
ConfigurationProvider
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: 1483 $
Author:
tmjee, Rainer Hermanns, Neo

Field Summary
private  String configFileName
           
private  Configuration configuration
           
private  List<Document> documents
           
private  Map<String,String> dtdMappings
           
private  boolean errorIfMissing
           
private  Set<String> includedFileNames
           
private  Set<String> loadedFileUrls
           
private static Log LOG
           
private  ObjectFactory objectFactory
           
 
Constructor Summary
XmlConfigurationProvider()
           
XmlConfigurationProvider(String filename)
           
XmlConfigurationProvider(String filename, boolean errorIfMissing)
           
 
Method Summary
protected  void addAction(Element actionElement, PackageConfig packageContext)
           
protected  PackageConfig addPackage(Element packageElement)
          Create a PackageConfig from an XML element representing it.
protected  void addResultTypes(PackageConfig packageContext, Element element)
           
protected  List buildExceptionMappings(Element element, PackageConfig packageContext)
          Build a map of ResultConfig objects from below a given XML element.
protected  List buildInterceptorList(Element element, PackageConfig context)
           
protected  PackageConfig buildPackageContext(Element packageElement)
          This method builds a package context by looking for the parents of this new package.
protected  Map buildResults(Element element, PackageConfig packageContext)
          Build a map of ResultConfig objects from below a given XML element.
 void destroy()
           
 boolean equals(Object o)
           
protected  Iterator<URL> getConfigurationUrls(String fileName)
           
 Map<String,String> getDtdMappings()
          Returns an unmodifiable map of DTD mappings
 int hashCode()
           
 void init(Configuration configuration)
           
private  List loadConfigurationFiles(String fileName, Element includeElement)
           
protected  void loadDefaultActionRef(PackageConfig packageContext, Element element)
           
protected  void loadDefaultClassRef(PackageConfig packageContext, Element element)
           
protected  void loadDefaultInterceptorRef(PackageConfig packageContext, Element element)
           
private  void loadDocuments(String configFileName)
           
protected  void loadExtraConfiguration(Document doc)
          Allows subclasses to load extra information from the document
protected  void loadGlobalResults(PackageConfig packageContext, Element packageElement)
          Load all of the global results for this package from the XML element.
protected  void loadGobalExceptionMappings(PackageConfig packageContext, Element packageElement)
          Load all of the global results for this package from the XML element.
protected  void loadInterceptors(PackageConfig context, Element element)
           
protected  InterceptorStackConfig loadInterceptorStack(Element element, PackageConfig context)
           
protected  void loadInterceptorStacks(Element element, PackageConfig context)
           
 void loadPackages()
           
private  List lookupInterceptorReference(PackageConfig context, Element interceptorRefElement)
          Looks up the Interceptor Class from the interceptor-ref name and creates an instance, which is added to the provided List, or, if this is a ref to a stack, it adds the Interceptor instances from the List to this stack.
 boolean needsReload()
          Tells whether the ConfigurationProvider should reload its configuration.
 void register(ContainerBuilder containerBuilder, LocatableProperties props)
           
private  void reloadRequiredPackages(List<Element> reloads)
           
 void setDtdMappings(Map<String,String> mappings)
           
 void setObjectFactory(ObjectFactory objectFactory)
           
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
 

Field Detail

LOG

private static final Log LOG

documents

private List<Document> documents

includedFileNames

private Set<String> includedFileNames

configFileName

private String configFileName

objectFactory

private ObjectFactory objectFactory

loadedFileUrls

private Set<String> loadedFileUrls

errorIfMissing

private boolean errorIfMissing

dtdMappings

private Map<String,String> dtdMappings

configuration

private Configuration configuration
Constructor Detail

XmlConfigurationProvider

public XmlConfigurationProvider()

XmlConfigurationProvider

public XmlConfigurationProvider(String filename)

XmlConfigurationProvider

public XmlConfigurationProvider(String filename,
                                boolean errorIfMissing)
Method Detail

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)
Specified by:
init in interface ConfigurationProvider

destroy

public void destroy()
Specified by:
destroy in interface ConfigurationProvider

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object

loadDocuments

private void loadDocuments(String configFileName)

register

public void register(ContainerBuilder containerBuilder,
                     LocatableProperties props)
              throws ConfigurationException
Specified by:
register in interface ConfigurationProvider
Throws:
ConfigurationException

loadPackages

public void loadPackages()
                  throws ConfigurationException
Specified by:
loadPackages in interface ConfigurationProvider
Throws:
ConfigurationException

reloadRequiredPackages

private void reloadRequiredPackages(List<Element> reloads)

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 ConfigurationProvider
Returns:
true if the file has been changed since the last time we read it

addAction

protected void addAction(Element actionElement,
                         PackageConfig 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 packageContext,
                              Element element)

verifyResultType

protected Class verifyResultType(String className,
                                 Location loc)

buildInterceptorList

protected List buildInterceptorList(Element element,
                                    PackageConfig context)
                             throws ConfigurationException
Throws:
ConfigurationException

buildPackageContext

protected PackageConfig 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 buildResults(Element element,
                           PackageConfig packageContext)
Build a map of ResultConfig objects from below a given XML element.


buildExceptionMappings

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


loadDefaultInterceptorRef

protected void loadDefaultInterceptorRef(PackageConfig packageContext,
                                         Element element)

loadDefaultActionRef

protected void loadDefaultActionRef(PackageConfig packageContext,
                                    Element element)

loadGlobalResults

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


loadDefaultClassRef

protected void loadDefaultClassRef(PackageConfig packageContext,
                                   Element element)

loadGobalExceptionMappings

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


loadInterceptorStack

protected InterceptorStackConfig loadInterceptorStack(Element element,
                                                      PackageConfig context)
                                               throws ConfigurationException
Throws:
ConfigurationException

loadInterceptorStacks

protected void loadInterceptorStacks(Element element,
                                     PackageConfig context)
                              throws ConfigurationException
Throws:
ConfigurationException

loadInterceptors

protected void loadInterceptors(PackageConfig context,
                                Element element)
                         throws ConfigurationException
Throws:
ConfigurationException

loadConfigurationFiles

private List loadConfigurationFiles(String fileName,
                                    Element includeElement)

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

lookupInterceptorReference

private List lookupInterceptorReference(PackageConfig context,
                                        Element interceptorRefElement)
                                 throws ConfigurationException
Looks up the Interceptor Class from the interceptor-ref name and creates an instance, which is added to the provided List, or, if this is a ref to a stack, it adds the Interceptor instances from the List to this stack.

Parameters:
interceptorRefElement - Element to pull interceptor ref data from
context - The PackageConfig to lookup the interceptor from
Returns:
A list of Interceptor objects
Throws:
ConfigurationException


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