org.apache.cocoon.core.container.spring.avalon
Class ConfigurationReader

java.lang.Object
  extended byorg.apache.cocoon.core.container.spring.avalon.ConfigurationReader

public class ConfigurationReader
extends Object

This component reads in Avalon style configuration files and returns all contained components and their configurations.

Since:
2.2
Version:
$Id: ConfigurationReader.html 1304280 2012-03-23 11:18:01Z ilgrosso $

Field Summary
protected  List componentConfigs
          All component configurations.
protected  ConfigurationInfo configInfo
          The configuration info.
protected  boolean isRootContext
          Is this the root context?
protected  Log logger
          Logger (we use the same logging mechanism as Spring!)
protected  ServletContextResourcePatternResolver resolver
          Resolver for reading configuration files.
 
Method Summary
protected  void configureRoles(Configuration configuration)
          Reads a configuration object and creates the role, shorthand, and class name mapping.
protected  void convert(Configuration config, Configuration additionalConfig, String rootUri)
           
protected  void convert(String relativePath)
           
protected  void convertSitemap(String sitemapLocation)
           
protected  String convertUrl(String url)
          Convert an avalon url (with possible cocoon protocols) to a spring url.
protected  String correctUrl(String url)
          Copied from ResourceUtils.correctUri(String).
protected  InputSource getInputSource(Resource rsrc)
          Construct input source from given Resource, initialize system Id.
protected  String getUrl(Resource rsrc)
           
protected  String getUrl(String url, String base)
           
protected  void handleBeanInclude(String contextURI, Configuration includeStatement)
          Handle include for spring bean configurations.
protected  void handleInclude(String contextURI, Set loadedURIs, Configuration includeStatement)
          Handle includes of avalon configurations.
protected  void loadURI(Resource src, Set loadedURIs, Configuration includeStatement)
           
protected  void parseConfiguration(Configuration configuration, String contextURI, Set loadedURIs)
           
protected  void processComponents()
           
static ConfigurationInfo readConfiguration(Configuration rolesConfig, Configuration componentConfig)
           
static ConfigurationInfo readConfiguration(String source, ResourceLoader resourceLoader)
          This method reads in an Avalon style configuration.
static ConfigurationInfo readSitemap(ConfigurationInfo parentInfo, String src, ResourceLoader resourceLoader)
          This method reads in an Avalon style sitemap.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final Log logger
Logger (we use the same logging mechanism as Spring!)


resolver

protected final ServletContextResourcePatternResolver resolver
Resolver for reading configuration files.


configInfo

protected final ConfigurationInfo configInfo
The configuration info.


componentConfigs

protected final List componentConfigs
All component configurations.


isRootContext

protected final boolean isRootContext
Is this the root context?

Method Detail

readConfiguration

public static ConfigurationInfo readConfiguration(String source,
                                                  ResourceLoader resourceLoader)
                                           throws Exception
This method reads in an Avalon style configuration.

Parameters:
source - The location of the configuration.
resourceLoader - The resource loader to load included configs.
Returns:
A configuration containing all defined objects.
Throws:
Exception

readSitemap

public static ConfigurationInfo readSitemap(ConfigurationInfo parentInfo,
                                            String src,
                                            ResourceLoader resourceLoader)
                                     throws Exception
This method reads in an Avalon style sitemap.

Parameters:
src - The location of the sitemap.
resourceLoader - The resource loader to load included configs.
Returns:
A configuration containing all defined objects.
Throws:
Exception

readConfiguration

public static ConfigurationInfo readConfiguration(Configuration rolesConfig,
                                                  Configuration componentConfig)
                                           throws Exception
Throws:
Exception

convertUrl

protected String convertUrl(String url)
Convert an avalon url (with possible cocoon protocols) to a spring url.

Parameters:
url - The avalon url.
Returns:
The spring url.

correctUrl

protected String correctUrl(String url)
Copied from ResourceUtils.correctUri(String). Comment says:
If it is a file we have to recreate the url, otherwise we get problems under windows with some file references starting with "/DRIVELETTER" and some just with "DRIVELETTER".

Parameters:
url - to correct
Returns:
corrected (or same) url

getUrl

protected String getUrl(Resource rsrc)
                 throws IOException
Throws:
IOException

getUrl

protected String getUrl(String url,
                        String base)

getInputSource

protected InputSource getInputSource(Resource rsrc)
                              throws IOException
Construct input source from given Resource, initialize system Id.

Parameters:
rsrc - Resource for the input source
Returns:
Input source
Throws:
Exception - if resource URL is not valid or input stream is not available
IOException

convert

protected void convert(String relativePath)
                throws Exception
Throws:
Exception

convertSitemap

protected void convertSitemap(String sitemapLocation)
                       throws Exception
Throws:
Exception

convert

protected void convert(Configuration config,
                       Configuration additionalConfig,
                       String rootUri)
                throws Exception
Throws:
Exception

parseConfiguration

protected void parseConfiguration(Configuration configuration,
                                  String contextURI,
                                  Set loadedURIs)
                           throws ConfigurationException
Throws:
ConfigurationException

processComponents

protected void processComponents()
                          throws ConfigurationException
Throws:
ConfigurationException

handleInclude

protected void handleInclude(String contextURI,
                             Set loadedURIs,
                             Configuration includeStatement)
                      throws ConfigurationException
Handle includes of avalon configurations.

Parameters:
contextURI -
loadedURIs -
includeStatement -
Throws:
ConfigurationException

loadURI

protected void loadURI(Resource src,
                       Set loadedURIs,
                       Configuration includeStatement)
                throws ConfigurationException,
                       IOException
Throws:
ConfigurationException
IOException

handleBeanInclude

protected void handleBeanInclude(String contextURI,
                                 Configuration includeStatement)
                          throws ConfigurationException
Handle include for spring bean configurations.

Parameters:
contextURI -
includeStatement -
Throws:
ConfigurationException

configureRoles

protected final void configureRoles(Configuration configuration)
                             throws ConfigurationException
Reads a configuration object and creates the role, shorthand, and class name mapping.

Parameters:
configuration - The configuration object.
Throws:
ConfigurationException - if the configuration is malformed


Copyright © 1999-2008 The Apache Software Foundation. All Rights Reserved.