cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r491292 - in /cocoon/trunk/core: cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/ cocoon-configuration/cocoon-spring-configurator/src/main/resources/org/apache/cocoon/spring/configura...
Date Sat, 30 Dec 2006 19:17:02 GMT
Author: cziegeler
Date: Sat Dec 30 11:17:02 2006
New Revision: 491292

URL: http://svn.apache.org/viewvc?view=rev&rev=491292
Log:
Further simplify child settings configuration
Move sitemap specific stuff to sitemap module
Removed import for single spring bean configuration from sitemap
Removed configuration of pattern for spring includes from sitemap

Removed:
    cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/SitemapNamespaceHandler.java
Modified:
    cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractElementParser.java
    cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsBeanFactoryPostProcessor.java
    cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsElementParser.java
    cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/Constants.java
    cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/SettingsElementParser.java
    cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-1.0.xsd
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapHelper.java

Modified: cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractElementParser.java?view=diff&rev=491292&r1=491291&r2=491292
==============================================================================
--- cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractElementParser.java
(original)
+++ cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractElementParser.java
Sat Dec 30 11:17:02 2006
@@ -222,57 +222,31 @@
      * Handle include for spring bean configurations.
      */
     protected void handleBeanInclude(final ParserContext parserContext,
-                                     final String        src,
                                      final String        path,
-                                     final String        pattern,
                                      final boolean       optional)
     throws Exception {
-        // TODO 'optional' parameter is ignored now 
         final ResourceLoader resourceLoader = parserContext.getReaderContext().getReader().getResourceLoader();
         ServletContextResourcePatternResolver resolver = new ServletContextResourcePatternResolver(resourceLoader);
 
-        final String includeURI = src;
-        String pathURI = null;
-        if (includeURI == null) {
-            // check for directories
-            pathURI = path;
-        }
-        if (includeURI == null && pathURI == null) {
-            throw new Exception("Include statement must either have a 'src' or 'dir' attribute.");
-        }
-
-        if (includeURI != null) {
-            Resource rsrc = resourceLoader.getResource(includeURI);
-            if ( rsrc.exists() ) {
-                try {
-                    this.handleImport(parserContext, rsrc.getURL().toExternalForm());
-                } catch (Exception e) {
-                    throw new Exception("Cannot load bean configuration '" + includeURI +
"'.", e);
-                }
-            } else if ( !optional ) {
-                throw new Exception("Unable to find bean configuration '" + includeURI +
"'.");    
+        // check if the directory to read from exists
+        // we only check if optional is set to true
+        boolean load = true;
+        if ( optional
+             && !ResourceUtils.isClasspathUri(path) ) {
+            final Resource rsrc = resolver.getResource(path);
+            if ( !rsrc.exists()) {
+                load = false;
             }
-        } else {
-            // check if the directory to read from exists
-            // we only check if optional is set to true
-            boolean load = true;
-            if ( optional
-                 && !ResourceUtils.isClasspathUri(pathURI) ) {
-                final Resource rsrc = resolver.getResource(pathURI);
-                if ( !rsrc.exists()) {
-                    load = false;
-                }
-            }
-            if ( load ) {
-                try {
-                    Resource[] resources = resolver.getResources(pathURI + '/' + pattern);
-                    Arrays.sort(resources, ResourceUtils.getResourceComparator());
-                    for (int i = 0; i < resources.length; i++) {
-                        this.handleImport(parserContext, resources[i].getURL().toExternalForm());
-                    }
-                } catch (IOException ioe) {
-                    throw new Exception("Unable to read configurations from " + pathURI,
ioe);
+        }
+        if ( load ) {
+            try {
+                Resource[] resources = resolver.getResources(path + "/*.xml");
+                Arrays.sort(resources, ResourceUtils.getResourceComparator());
+                for (int i = 0; i < resources.length; i++) {
+                    this.handleImport(parserContext, resources[i].getURL().toExternalForm());
                 }
+            } catch (IOException ioe) {
+                throw new Exception("Unable to read configurations from " + path, ioe);
             }
         }
     }

Modified: cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsBeanFactoryPostProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsBeanFactoryPostProcessor.java?view=diff&rev=491292&r1=491291&r2=491292
==============================================================================
--- cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsBeanFactoryPostProcessor.java
(original)
+++ cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsBeanFactoryPostProcessor.java
Sat Dec 30 11:17:02 2006
@@ -29,7 +29,6 @@
 import org.apache.cocoon.spring.configurator.ResourceUtils;
 import org.springframework.beans.factory.BeanFactory;
 import org.springframework.beans.factory.HierarchicalBeanFactory;
-import org.springframework.core.io.Resource;
 
 /**
  * This is a bean factory post processor which sets up a child settings object.
@@ -40,12 +39,12 @@
 public class ChildSettingsBeanFactoryPostProcessor
     extends AbstractSettingsBeanFactoryPostProcessor {
 
-    protected String location;
+    /** Unique name for this child settings context. */
+    protected String name;
 
+    /** List of property directories. */
     protected List directories;
 
-    protected boolean useDefaultIncludes = true;
-
     /**
      * Initialize this settings.
      * Setup the settings object.
@@ -61,8 +60,8 @@
         this.settings.makeReadOnly();
     }
 
-    public void setLocation(String sitemapUri) {
-        this.location = sitemapUri;
+    public void setName(String newName) {
+        this.name = newName;
     }
 
     public void setDirectories(List directories) {
@@ -73,10 +72,6 @@
         this.additionalProperties = props;
     }
 
-    public void setUseDefaultIncludes(boolean useDefaultIncludes) {
-        this.useDefaultIncludes = useDefaultIncludes;
-    }
-
     /**
      * Get the settings for Cocoon.
      * This method reads several property files and merges the result. If there
@@ -101,13 +96,6 @@
         // create an empty settings objects
         final MutableSettings s = new MutableSettings(parent);
 
-        // read properties from default includes
-        if ( this.useDefaultIncludes ) {
-            ResourceUtils.readProperties(Constants.DEFAULT_CHILD_PROPERTIES_LOCATION, properties,
this.getResourceLoader(), this.logger);
-            // read all properties from the mode dependent directory
-            ResourceUtils.readProperties(Constants.DEFAULT_CHILD_PROPERTIES_LOCATION + '/'
+ mode, properties, this.getResourceLoader(), this.logger);    
-        }
-
         if ( this.directories != null ) {
             final Iterator i = directories.iterator();
             while ( i.hasNext() ) {
@@ -122,9 +110,8 @@
         // Next look for a custom property provider in the parent bean factory
         if (parentBeanFactory.containsBean(PropertyProvider.ROLE) ) {
             try {
-                final Resource r = this.resourceLoader.getResource(this.location);
                 final PropertyProvider provider = (PropertyProvider)parentBeanFactory.getBean(PropertyProvider.ROLE);
-                final Properties providedProperties = provider.getProperties(s, mode, r.getURL().toExternalForm());
+                final Properties providedProperties = provider.getProperties(s, mode, this.name);
                 if ( providedProperties != null ) {
                     properties.putAll(providedProperties);
                 }

Modified: cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsElementParser.java?view=diff&rev=491292&r1=491291&r2=491292
==============================================================================
--- cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsElementParser.java
(original)
+++ cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/ChildSettingsElementParser.java
Sat Dec 30 11:17:02 2006
@@ -19,15 +19,17 @@
 package org.apache.cocoon.spring.configurator.impl;
 
 import java.util.ArrayList;
-import java.util.Collections;
+import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
 
 import org.apache.cocoon.configuration.Settings;
+import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.springframework.beans.factory.BeanDefinitionStoreException;
 import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.support.RootBeanDefinition;
 import org.springframework.beans.factory.xml.ParserContext;
+import org.springframework.web.context.WebApplicationContext;
 import org.w3c.dom.Element;
 
 /**
@@ -77,60 +79,82 @@
      * @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element,
org.springframework.beans.factory.xml.ParserContext)
      */
     public BeanDefinition parse(Element element, ParserContext parserContext) {
-        final String runningMode = RunningModeHelper.determineRunningMode( this.getAttributeValue(element,
SettingsElementParser.RUNNING_MODE_ATTR, null) );
-        final String location = element.getAttribute("location");
+        // get root application context
+        final WebApplicationContext rootAppContext = WebAppContextUtils.getCurrentWebApplicationContext();
+        // get running mode from root settings
+        final String runningMode = ((Settings)rootAppContext.getBean(Settings.ROLE)).getRunningMode();
         try {
-            final boolean useDefaultIncludes = Boolean.valueOf(this.getAttributeValue(element,
"useDefaultIncludes", "true")).booleanValue();
+            // Get bean includes
+            final List beanIncludes = this.getBeanIncludes(element);
 
-            // register a PropertyPlaceholderConfigurer
-            if ( useDefaultIncludes ) {
-                this.registerPropertyOverrideConfigurer(parserContext, Collections.singletonList(Constants.DEFAULT_CHILD_SPRING_CONFIGURATION_LOCATION));
+            // If there are bean includes for a directory, we register a property placeholder
configurer
+            if ( beanIncludes.size() > 0 ) {
+                // we need a list of directories
+                final List dirs = new ArrayList(beanIncludes.size());
+                final Iterator i = beanIncludes.iterator();
+                while ( i.hasNext() ) {
+                    dirs.add(((IncludeInfo)i.next()).dir);
+                }
+                this.registerPropertyOverrideConfigurer(parserContext, dirs); 
             }
-            
+
+            // Create definition for child settings
             RootBeanDefinition def =  this.createBeanDefinition(ChildSettingsBeanFactoryPostProcessor.class.getName(),
                     "init",
                     false);
-            def.getPropertyValues().addPropertyValue("location", location);
-            def.getPropertyValues().addPropertyValue("useDefaultIncludes", Boolean.valueOf(useDefaultIncludes));
+            def.getPropertyValues().addPropertyValue("name", element.getAttribute("name"));
 
             final Properties additionalProps = this.getAdditionalProperties(element);
             if ( additionalProps != null ) {
                 def.getPropertyValues().addPropertyValue("additionalProperties", additionalProps);
               
             }
 
-            final List includes = this.getPropertyIncludes(element);
-            if ( includes != null ) {
-                def.getPropertyValues().addPropertyValue("directories", includes);
-            }
-
-            if ( useDefaultIncludes ) {
-                this.handleBeanInclude(parserContext, null, Constants.DEFAULT_CHILD_SPRING_CONFIGURATION_LOCATION,
"*.xml", true);
-                this.handleBeanInclude(parserContext, null, Constants.DEFAULT_CHILD_SPRING_CONFIGURATION_LOCATION
+ "/" + runningMode, "*.xml", true);
-            }
-            // search for includes
-            if ( element.hasChildNodes() ) {
-                final Element[] includeElements = this.getChildElements(element, "include-beans");
-                if ( includeElements != null ) {
-                    for(int i = 0 ; i < includeElements.length; i++ ) {
-                        final String src = this.getAttributeValue(includeElements[i], "src",
null);
-                        final String dir = this.getAttributeValue(includeElements[i], "dir",
null);
-                        final String pattern = this.getAttributeValue(includeElements[i],
"pattern", "*.xml");
-                        final boolean optional = Boolean.valueOf(this.getAttributeValue(includeElements[i],
"optional", "false")).booleanValue();
-
-                        this.handleBeanInclude(parserContext, src, dir, pattern, optional);
-
-                        // TODO do we really need both src/dir attributes? The
-                        // quiet precedence of 'src' over 'dir' attribute is at
-                        // least unclear.
-                        if (src == null && dir != null)
-                            this.handleBeanInclude(parserContext, null, dir + "/" + runningMode,
pattern, optional);
-                    }
-                }
+            final List propertiesIncludes = this.getPropertyIncludes(element);
+            if ( propertiesIncludes != null ) {
+                def.getPropertyValues().addPropertyValue("directories", propertiesIncludes);
+            }
+
+            // process bean includes!
+            final Iterator beanIncludeIterator = beanIncludes.iterator();
+            while ( beanIncludeIterator.hasNext() ) {
+                final IncludeInfo info = (IncludeInfo)beanIncludeIterator.next();
+
+                this.handleBeanInclude(parserContext, info.dir, info.optional);
+                this.handleBeanInclude(parserContext, info.dir + "/" + runningMode, true);
             }
+
+            // and now we register the child settings
             this.register(def, Settings.ROLE, parserContext.getRegistry());
         } catch (Exception e) {
-            throw new BeanDefinitionStoreException("Unable to process sitemap at '" + location
+ "'.",e);
+            throw new BeanDefinitionStoreException("Unable to process child settings element.",
e);
         }
         return null;
+    }
+
+    protected List getBeanIncludes(Element childSettingsElement) {
+        final List includes = new ArrayList();
+        // search for includes
+        if ( childSettingsElement.hasChildNodes() ) {
+            final Element[] includeElements = this.getChildElements(childSettingsElement,
"include-beans");
+            if ( includeElements != null ) {
+                for(int i = 0 ; i < includeElements.length; i++ ) {
+                    final String dir = this.getAttributeValue(includeElements[i], "dir",
null);
+                    final boolean optional = Boolean.valueOf(this.getAttributeValue(includeElements[i],
"optional", "false")).booleanValue();
+
+                    includes.add(new IncludeInfo(dir, optional));
+                }
+            }
+        }
+        return includes;
+    }
+
+    protected static final class IncludeInfo {
+        public final String dir;
+        public final boolean optional;
+
+        public IncludeInfo(String d, boolean o) {
+            this.dir = d;
+            this.optional = o;
+        }
     }
 }

Modified: cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/Constants.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/Constants.java?view=diff&rev=491292&r1=491291&r2=491292
==============================================================================
--- cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/Constants.java
(original)
+++ cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/Constants.java
Sat Dec 30 11:17:02 2006
@@ -48,15 +48,4 @@
      * The location of global property files (*.properties) for the settings.
      */
     public static final String GLOBAL_PROPERTIES_LOCATION = "/WEB-INF/cocoon/properties";
-
-    /**
-     * The default location of spring related child configuration files.
-     * TODO Move this to the sitemap handler
-     */
-    public static final String DEFAULT_CHILD_SPRING_CONFIGURATION_LOCATION = "config/spring";
-    /**
-     * The default location of spring related child configuration files.
-     * TODO Move this to the sitemap handler
-     */
-    public static final String DEFAULT_CHILD_PROPERTIES_LOCATION = "config/properties";
 }

Modified: cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/SettingsElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/SettingsElementParser.java?view=diff&rev=491292&r1=491291&r2=491292
==============================================================================
--- cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/SettingsElementParser.java
(original)
+++ cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/SettingsElementParser.java
Sat Dec 30 11:17:02 2006
@@ -91,16 +91,16 @@
 
         // handle includes
         try {
-            this.handleBeanInclude(parserContext, null, Constants.CLASSPATH_SPRING_CONFIGURATION_LOCATION,
"*.xml", true);
-            this.handleBeanInclude(parserContext, null, Constants.CLASSPATH_SPRING_CONFIGURATION_LOCATION
+ "/" + runningMode, "*.xml", true);
+            this.handleBeanInclude(parserContext, Constants.CLASSPATH_SPRING_CONFIGURATION_LOCATION,
true);
+            this.handleBeanInclude(parserContext, Constants.CLASSPATH_SPRING_CONFIGURATION_LOCATION
+ "/" + runningMode, true);
         } catch (Exception e) {
             throw new BeanDefinitionStoreException("Unable to read spring configurations
from " + Constants.CLASSPATH_SPRING_CONFIGURATION_LOCATION, e);
         }
 
         if ( springConfigLocation != null ) {
             try {
-                this.handleBeanInclude(parserContext, null, springConfigLocation, "*.xml",
true);
-                this.handleBeanInclude(parserContext, null, springConfigLocation + "/" +
runningMode, "*.xml", true);            
+                this.handleBeanInclude(parserContext, springConfigLocation, true);
+                this.handleBeanInclude(parserContext, springConfigLocation + "/" + runningMode,
true);            
             } catch (Exception e) {
                 throw new BeanDefinitionStoreException("Unable to read spring configurations
from " + springConfigLocation, e);
             }

Modified: cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-1.0.xsd
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-1.0.xsd?view=diff&rev=491292&r1=491291&r2=491292
==============================================================================
--- cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-1.0.xsd
(original)
+++ cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/resources/org/apache/cocoon/spring/configurator/schema/cocoon-configurator-1.0.xsd
Sat Dec 30 11:17:02 2006
@@ -36,17 +36,13 @@
     	    <xsd:element ref="include-properties" minOccurs="0" maxOccurs="unbounded"/>
     	    <xsd:element ref="property" minOccurs="0" maxOccurs="unbounded"/>
     	</xsd:sequence>
-    	<xsd:attribute name="location" type="xsd:string" use="required"/>
-    	<xsd:attribute name="runningMode" type="xsd:string" use="optional"/>
-    	<xsd:attribute name="useDefaultIncludes" type="xsd:boolean"	use="optional"/>
+    	<xsd:attribute name="name" type="xsd:string" use="required"/>
       </xsd:complexType>
     </xsd:element>
 
     <xsd:element name="include-beans">
       <xsd:complexType>
-    	<xsd:attribute name="src" type="xsd:string" use="optional"/>
     	<xsd:attribute name="dir" type="xsd:string" use="optional"/>
-    	<xsd:attribute name="pattern" type="xsd:string" use="optional"/>
     	<xsd:attribute name="optional" type="xsd:boolean" use="optional"/>
       </xsd:complexType>
     </xsd:element>

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapHelper.java?view=diff&rev=491292&r1=491291&r2=491292
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapHelper.java
(original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapHelper.java
Sat Dec 30 11:17:02 2006
@@ -30,7 +30,6 @@
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.configuration.DefaultConfiguration;
 import org.apache.cocoon.classloader.reloading.Monitor;
-import org.apache.cocoon.configuration.Settings;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.processing.ProcessInfoProvider;
@@ -54,10 +53,17 @@
 
     private static final String DEFAULT_CONFIG_XCONF  = "config/avalon";
 
+    /**
+     * The default location of spring related child configuration files.
+     */
+    public static final String DEFAULT_CHILD_SPRING_CONFIGURATION_LOCATION = "config/spring";
+    /**
+     * The default location of spring related child configuration files.
+     */
+    public static final String DEFAULT_CHILD_PROPERTIES_LOCATION = "config/properties";
+
     protected static String createDefinition(String     uriPrefix,
                                              String     sitemapLocation,
-                                             String     runningMode,
-                                             boolean    useDefaultIncludes,
                                              List       beanIncludes,
                                              List       propertyIncludes,
                                              Properties props) {
@@ -65,18 +71,14 @@
         addHeader(buffer);
         // Child settings for sitemap
         buffer.append("  <configurator:child-settings");
-        addAttribute(buffer, "location", sitemapLocation);
-        addAttribute(buffer, "runningMode", runningMode);
-        addAttribute(buffer, "useDefaultIncludes", String.valueOf(useDefaultIncludes));
+        addAttribute(buffer, "name", sitemapLocation);
         buffer.append(">\n");
         if ( beanIncludes != null ) {
             final Iterator i = beanIncludes.iterator();
             while ( i.hasNext() ) {
                 final IncludeInfo info = (IncludeInfo)i.next();
                 buffer.append("    <configurator:include-beans");
-                addAttribute(buffer, "src", info.src);
                 addAttribute(buffer, "dir", info.dir);
-                addAttribute(buffer, "pattern", info.pattern);
                 addAttribute(buffer, "optional", String.valueOf(info.optional));
                 buffer.append("/>\n");
             }
@@ -107,6 +109,7 @@
         addAttribute(buffer, "uriPrefix", uriPrefix);
         buffer.append("/>\n");
         addFooter(buffer);
+
         return buffer.toString();
     }
 
@@ -160,20 +163,15 @@
     protected static List getBeanIncludes(Configuration sitemap)
     throws ConfigurationException {
         final List includes = new ArrayList();
+        if ( isUsingDefaultIncludes(sitemap) ) {
+            includes.add(new IncludeInfo(DEFAULT_CHILD_SPRING_CONFIGURATION_LOCATION, true));
+        }
         final Configuration[] includeConfigs = sitemap.getChild("components").getChildren("include-beans");
         for(int i = 0 ; i < includeConfigs.length; i++ ) {
-            final String src = includeConfigs[i].getAttribute("src", null);
-            final String dir = includeConfigs[i].getAttribute("dir", null);
-            final String pattern = includeConfigs[i].getAttribute("pattern", "*.xml");
+            final String dir = includeConfigs[i].getAttribute("dir");
             final boolean optional = includeConfigs[i].getAttributeAsBoolean("optional",
false);
 
-            if ( src != null && dir != null ) {
-                throw new ConfigurationException("Element include-beans can either be configured
with a directory or with a src, but not with both.", includeConfigs[i]);
-            }
-            if ( src == null && dir == null ) {
-                throw new ConfigurationException("Element include-beans must either be configured
with a directory or with a src.", includeConfigs[i]);
-            }
-            includes.add(new IncludeInfo(src, dir, pattern, optional));
+            includes.add(new IncludeInfo(dir, optional));
         }
         return includes;
     }
@@ -186,11 +184,14 @@
     protected static List getPropertiesIncludes(Configuration sitemap)
     throws ConfigurationException {
         final List includes = new ArrayList();
+        if ( isUsingDefaultIncludes(sitemap) ) {
+            includes.add(new IncludeInfo(DEFAULT_CHILD_PROPERTIES_LOCATION, true));
+        }
         final Configuration[] includeConfigs = sitemap.getChild("components").getChildren("include-properties");
         for(int i = 0 ; i < includeConfigs.length; i++ ) {
             final String dir = includeConfigs[i].getAttribute("dir");
 
-            includes.add(new IncludeInfo(null, dir, null, true));
+            includes.add(new IncludeInfo(dir, true));
         }
         return includes;
     }
@@ -298,8 +299,6 @@
         // create root bean definition
         final String definition = createDefinition(request.getSitemapURIPrefix(),
                                                    sitemapLocation.substring(pos+1),
-                                                   ((Settings)parentContext.getBean(Settings.ROLE)).getRunningMode(),
-                                                   isUsingDefaultIncludes(config),
                                                    getBeanIncludes(config),
                                                    getPropertiesIncludes(config),
                                                    getGlobalSitemapVariables(config));
@@ -353,15 +352,11 @@
 //    }
 
     protected static final class IncludeInfo {
-        public final String src;
         public final String dir;
-        public final String pattern;
         public final boolean optional;
 
-        public IncludeInfo(String s, String d, String p, boolean o) {
-            this.src = s;
+        public IncludeInfo(String d, boolean o) {
             this.dir = d;
-            this.pattern = p;
             this.optional = o;
         }
     }



Mime
View raw message