cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r491021 - /cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/
Date Fri, 29 Dec 2006 14:53:57 GMT
Author: cziegeler
Date: Fri Dec 29 06:53:56 2006
New Revision: 491021

URL: http://svn.apache.org/viewvc?view=rev&rev=491021
Log:
We can use several locations now

Modified:
    cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/AbstractElementParser.java
    cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/CocoonPropertyOverrideConfigurer.java
    cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/Constants.java
    cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/SettingsBeanFactoryPostProcessor.java
    cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/SettingsElementParser.java

Modified: cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/AbstractElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/AbstractElementParser.java?view=diff&rev=491021&r1=491020&r2=491021
==============================================================================
--- cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/AbstractElementParser.java
(original)
+++ cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/AbstractElementParser.java
Fri Dec 29 06:53:56 2006
@@ -20,6 +20,7 @@
 
 import java.io.IOException;
 import java.util.Arrays;
+import java.util.Collections;
 
 import org.apache.cocoon.configuration.Settings;
 import org.apache.cocoon.spring.ResourceUtils;
@@ -275,7 +276,7 @@
                                                       final String        location) {
         final RootBeanDefinition beanDef = this.createBeanDefinition(CocoonPropertyOverrideConfigurer.class.getName(),
                 null, true);
-        beanDef.getPropertyValues().addPropertyValue("location", location);
+        beanDef.getPropertyValues().addPropertyValue("locations", Collections.singletonList(location));
         beanDef.getPropertyValues().addPropertyValue("resourceLoader",
                 parserContext.getReaderContext().getReader().getResourceLoader());
         beanDef.getPropertyValues().addPropertyValue("beanNameSeparator", "/");

Modified: cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/CocoonPropertyOverrideConfigurer.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/CocoonPropertyOverrideConfigurer.java?view=diff&rev=491021&r1=491020&r2=491021
==============================================================================
--- cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/CocoonPropertyOverrideConfigurer.java
(original)
+++ cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/CocoonPropertyOverrideConfigurer.java
Fri Dec 29 06:53:56 2006
@@ -18,6 +18,9 @@
  */
 package org.apache.cocoon.spring.impl;
 
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
 import java.util.Properties;
 
 import org.apache.cocoon.configuration.Settings;
@@ -40,10 +43,10 @@
 public class CocoonPropertyOverrideConfigurer extends PropertyOverrideConfigurer {
 
     /**
-     * The location of the directory where the different property files are
+     * The locations of the directories where the different property files are
      * located.
      */
-    protected String location = Constants.DEFAULT_SPRING_CONFIGURATION_LOCATION;
+    protected List locations = Collections.singletonList(Constants.DEFAULT_CLASSPATH_SPRING_CONFIGURATION_LOCATION);
 
     /**
      * The resource loader used to load the property files. This loader is
@@ -58,13 +61,12 @@
     protected Settings settings;
 
     /**
-     * Set the directory to search in.
+     * Set the directories to search in.
      * 
-     * @param object
-     *            New value.
+     * @param list     A list of string pointing to directories.
      */
-    public void setLocation(final String object) {
-        this.location = object;
+    public void setLocations(final List list) {
+        this.locations = list;
     }
 
     /** Set the settings. */
@@ -95,9 +97,15 @@
         final String mode = RunningModeHelper.determineRunningMode(this.settings != null
? this.settings.getRunningMode() : null);
         final Properties mergedProps = new Properties();
 
-        ResourceUtils.readProperties(this.location, mergedProps, this.resourceLoader, this.logger);
-        // read properties from running-mode dependent directory
-        ResourceUtils.readProperties(this.location + '/' + mode, mergedProps, this.resourceLoader,
this.logger);
+        if ( this.locations != null ) {
+            final Iterator i = this.locations.iterator();
+            while ( i.hasNext() ) {
+                final String location = (String)i.next();
+                ResourceUtils.readProperties(location, mergedProps, this.resourceLoader,
this.logger);
+                // read properties from running-mode dependent directory
+                ResourceUtils.readProperties(location + '/' + mode, mergedProps, this.resourceLoader,
this.logger);
+            }
+        }
 
         if (mergedProps.size() > 0) {
             // Convert the merged properties, if necessary.

Modified: cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/Constants.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/Constants.java?view=diff&rev=491021&r1=491020&r2=491021
==============================================================================
--- cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/Constants.java
(original)
+++ cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/Constants.java
Fri Dec 29 06:53:56 2006
@@ -27,6 +27,6 @@
 public abstract class Constants {
 
     /** The default location of spring related configuration files. */
-    public static final String DEFAULT_SPRING_CONFIGURATION_LOCATION = "classpath*:META-INF/cocoon/spring";
-    public static final String DEFAULT_PROPERTIES_LOCATION = "classpath*:META-INF/cocoon/properties";
+    public static final String DEFAULT_CLASSPATH_SPRING_CONFIGURATION_LOCATION = "classpath*:META-INF/cocoon/spring";
+    public static final String DEFAULT_CLASSPATH_PROPERTIES_LOCATION = "classpath*:META-INF/cocoon/properties";
 }

Modified: cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/SettingsBeanFactoryPostProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/SettingsBeanFactoryPostProcessor.java?view=diff&rev=491021&r1=491020&r2=491021
==============================================================================
--- cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/SettingsBeanFactoryPostProcessor.java
(original)
+++ cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/SettingsBeanFactoryPostProcessor.java
Fri Dec 29 06:53:56 2006
@@ -165,10 +165,10 @@
         final Properties properties = new Properties();
 
         // now read all properties from the properties directory
-        ResourceUtils.readProperties(org.apache.cocoon.spring.impl.Constants.DEFAULT_PROPERTIES_LOCATION,
+        ResourceUtils.readProperties(org.apache.cocoon.spring.impl.Constants.DEFAULT_CLASSPATH_PROPERTIES_LOCATION,
                 properties, this.getResourceLoader(), this.logger);
         // read all properties from the mode dependent directory
-        ResourceUtils.readProperties(org.apache.cocoon.spring.impl.Constants.DEFAULT_PROPERTIES_LOCATION
+        ResourceUtils.readProperties(org.apache.cocoon.spring.impl.Constants.DEFAULT_CLASSPATH_PROPERTIES_LOCATION
                 + "/" + mode, properties, this.getResourceLoader(), this.logger);
 
         // fill from the servlet context

Modified: cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/SettingsElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/SettingsElementParser.java?view=diff&rev=491021&r1=491020&r2=491021
==============================================================================
--- cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/SettingsElementParser.java
(original)
+++ cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/impl/SettingsElementParser.java
Fri Dec 29 06:53:56 2006
@@ -54,7 +54,7 @@
      */
     public BeanDefinition parse(Element element, ParserContext parserContext) {
         final String springConfigLocation = this.getAttributeValue(element, "location",
-                Constants.DEFAULT_SPRING_CONFIGURATION_LOCATION);
+                Constants.DEFAULT_CLASSPATH_SPRING_CONFIGURATION_LOCATION);
 
         // create bean definition for settings object
         final String componentClassName = this.getAttributeValue(element, PROCESSOR_CLASS_NAME_ATTR,
@@ -83,10 +83,10 @@
 
         // handle includes
         try {
-            this.handleBeanInclude(parserContext, null, Constants.DEFAULT_SPRING_CONFIGURATION_LOCATION,
"*.xml", true);
-            this.handleBeanInclude(parserContext, null, Constants.DEFAULT_SPRING_CONFIGURATION_LOCATION
+ "/" + runningMode, "*.xml", true);
+            this.handleBeanInclude(parserContext, null, Constants.DEFAULT_CLASSPATH_SPRING_CONFIGURATION_LOCATION,
"*.xml", true);
+            this.handleBeanInclude(parserContext, null, Constants.DEFAULT_CLASSPATH_SPRING_CONFIGURATION_LOCATION
+ "/" + runningMode, "*.xml", true);
         } catch (Exception e) {
-            throw new BeanDefinitionStoreException("Unable to read spring configurations
from " + Constants.DEFAULT_SPRING_CONFIGURATION_LOCATION, e);
+            throw new BeanDefinitionStoreException("Unable to read spring configurations
from " + Constants.DEFAULT_CLASSPATH_SPRING_CONFIGURATION_LOCATION, e);
         }
 
         return null;



Mime
View raw message