cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r491417 - 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 Sun, 31 Dec 2006 12:21:53 GMT
Author: cziegeler
Date: Sun Dec 31 04:21:52 2006
New Revision: 491417

URL: http://svn.apache.org/viewvc?view=rev&rev=491417
Log:
Remove optional parameter for directory configurations

Modified:
    cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractSettingsElementParser.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/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/AbstractSettingsElementParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractSettingsElementParser.java?view=diff&rev=491417&r1=491416&r2=491417
==============================================================================
--- cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractSettingsElementParser.java
(original)
+++ cocoon/trunk/core/cocoon-configuration/cocoon-spring-configurator/src/main/java/org/apache/cocoon/spring/configurator/impl/AbstractSettingsElementParser.java
Sun Dec 31 04:21:52 2006
@@ -78,22 +78,11 @@
             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));
+                    includes.add(dir);
                 }
             }
         }
         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/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=491417&r1=491416&r2=491417
==============================================================================
--- 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
Sun Dec 31 04:21:52 2006
@@ -18,7 +18,6 @@
  */
 package org.apache.cocoon.spring.configurator.impl;
 
-import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.Properties;
@@ -57,13 +56,7 @@
 
         // 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); 
+            this.registerPropertyOverrideConfigurer(parserContext, beanIncludes); 
         }
 
         // Create definition for child settings
@@ -85,13 +78,13 @@
         // process bean includes!
         final Iterator beanIncludeIterator = beanIncludes.iterator();
         while ( beanIncludeIterator.hasNext() ) {
-            final IncludeInfo info = (IncludeInfo)beanIncludeIterator.next();
+            final String dir = (String)beanIncludeIterator.next();
 
             try {
-                this.handleBeanInclude(parserContext, info.dir, info.optional);
-                this.handleBeanInclude(parserContext, info.dir + "/" + runningMode, true);
+                this.handleBeanInclude(parserContext, dir, false);
+                this.handleBeanInclude(parserContext, dir + "/" + runningMode, true);
             } catch (Exception e) {
-                throw new BeanDefinitionStoreException("Unable to read spring configurations
from " + info.dir, e);
+                throw new BeanDefinitionStoreException("Unable to read spring configurations
from " + dir, e);
             }
         }
 

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=491417&r1=491416&r2=491417
==============================================================================
--- 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
Sun Dec 31 04:21:52 2006
@@ -113,11 +113,7 @@
         }
         // If there are bean includes for a directory, we register them as well
         if ( beanIncludes.size() > 0 ) {
-            // we need a list of directories
-            final Iterator i = beanIncludes.iterator();
-            while ( i.hasNext() ) {
-                dirs.add(((IncludeInfo)i.next()).dir);
-            }
+            dirs.addAll(beanIncludes);
         }
         if ( dirs.size() > 0 ) {
             this.registerPropertyOverrideConfigurer(parserContext, dirs);
@@ -135,19 +131,19 @@
 
         // handle includes - add default location
         if ( readFromClasspath ) {
-            beanIncludes.add(0, new IncludeInfo(Constants.CLASSPATH_SPRING_CONFIGURATION_LOCATION,
true));
+            beanIncludes.add(0, Constants.CLASSPATH_SPRING_CONFIGURATION_LOCATION);
         }
 
         // process bean includes!
         final Iterator beanIncludeIterator = beanIncludes.iterator();
         while ( beanIncludeIterator.hasNext() ) {
-            final IncludeInfo info = (IncludeInfo)beanIncludeIterator.next();
+            final String dir = (String)beanIncludeIterator.next();
 
             try {
-                this.handleBeanInclude(parserContext, info.dir, info.optional);
-                this.handleBeanInclude(parserContext, info.dir + "/" + runningMode, true);
+                this.handleBeanInclude(parserContext, dir, false);
+                this.handleBeanInclude(parserContext, dir + "/" + runningMode, true);
             } catch (Exception e) {
-                throw new BeanDefinitionStoreException("Unable to read spring configurations
from " + info.dir, e);
+                throw new BeanDefinitionStoreException("Unable to read spring configurations
from " + dir, 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=491417&r1=491416&r2=491417
==============================================================================
--- 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
Sun Dec 31 04:21:52 2006
@@ -48,7 +48,6 @@
     <xsd:element name="include-beans">
       <xsd:complexType>
     	<xsd:attribute name="dir" 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=491417&r1=491416&r2=491417
==============================================================================
--- 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
Sun Dec 31 04:21:52 2006
@@ -36,6 +36,7 @@
 import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.cocoon.spring.configurator.impl.ChildXmlWebApplicationContext;
 import org.apache.cocoon.util.Deprecation;
+import org.springframework.core.io.Resource;
 import org.springframework.web.context.WebApplicationContext;
 import org.springframework.web.context.support.WebApplicationContextUtils;
 
@@ -76,19 +77,18 @@
         if ( beanIncludes != null ) {
             final Iterator i = beanIncludes.iterator();
             while ( i.hasNext() ) {
-                final IncludeInfo info = (IncludeInfo)i.next();
+                final String dir = (String)i.next();
                 buffer.append("    <configurator:include-beans");
-                addAttribute(buffer, "dir", info.dir);
-                addAttribute(buffer, "optional", String.valueOf(info.optional));
+                addAttribute(buffer, "dir", dir);
                 buffer.append("/>\n");
             }
         }
         if ( propertyIncludes != null ) {
             final Iterator i = propertyIncludes.iterator();
             while ( i.hasNext() ) {
-                final IncludeInfo info = (IncludeInfo)i.next();
+                final String dir = (String)i.next();
                 buffer.append("    <configurator:include-properties");
-                addAttribute(buffer, "dir", info.dir);
+                addAttribute(buffer, "dir", dir);
                 buffer.append("/>\n");
             }
         }
@@ -160,18 +160,22 @@
      * @param sitemap
      * @return
      */
-    protected static List getBeanIncludes(Configuration sitemap)
+    protected static List getBeanIncludes(WebApplicationContext webAppContext,
+                                          String                contextUrl,
+                                          Configuration         sitemap)
     throws ConfigurationException {
         final List includes = new ArrayList();
         if ( isUsingDefaultIncludes(sitemap) ) {
-            includes.add(new IncludeInfo(DEFAULT_CHILD_SPRING_CONFIGURATION_LOCATION, true));
+            final Resource rsrc = webAppContext.getResource(contextUrl + DEFAULT_CHILD_SPRING_CONFIGURATION_LOCATION);
+            if ( rsrc.exists() ) {
+                includes.add(DEFAULT_CHILD_SPRING_CONFIGURATION_LOCATION);
+            }
         }
         final Configuration[] includeConfigs = sitemap.getChild("components").getChildren("include-beans");
         for(int i = 0 ; i < includeConfigs.length; i++ ) {
             final String dir = includeConfigs[i].getAttribute("dir");
-            final boolean optional = includeConfigs[i].getAttributeAsBoolean("optional",
false);
 
-            includes.add(new IncludeInfo(dir, optional));
+            includes.add(dir);
         }
         return includes;
     }
@@ -181,17 +185,22 @@
      * @param sitemap
      * @return
      */
-    protected static List getPropertiesIncludes(Configuration sitemap)
+    protected static List getPropertiesIncludes(WebApplicationContext webAppContext,
+                                                String                contextUrl,
+                                                Configuration         sitemap)
     throws ConfigurationException {
         final List includes = new ArrayList();
         if ( isUsingDefaultIncludes(sitemap) ) {
-            includes.add(new IncludeInfo(DEFAULT_CHILD_PROPERTIES_LOCATION, true));
+            final Resource rsrc = webAppContext.getResource(contextUrl + DEFAULT_CHILD_PROPERTIES_LOCATION);
+            if ( rsrc.exists() ) {
+                includes.add(DEFAULT_CHILD_PROPERTIES_LOCATION);
+            }
         }
         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(dir, true));
+            includes.add(dir);
         }
         return includes;
     }
@@ -299,8 +308,8 @@
         // create root bean definition
         final String definition = createDefinition(request.getSitemapURIPrefix(),
                                                    sitemapLocation.substring(pos+1),
-                                                   getBeanIncludes(config),
-                                                   getPropertiesIncludes(config),
+                                                   getBeanIncludes(parentContext, contextUrl,
config),
+                                                   getPropertiesIncludes(parentContext, contextUrl,
config),
                                                    getGlobalSitemapVariables(config));
         PARENT_CONTEXT.set(parentContext);
         try {
@@ -350,14 +359,4 @@
 //                                           configBean,
 //                                           servletContext);
 //    }
-
-    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;
-        }
-    }
 }



Mime
View raw message