You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/08/29 22:49:27 UTC

svn commit: r438205 - in /cocoon/trunk: blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/ blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modul...

Author: cziegeler
Date: Tue Aug 29 13:49:26 2006
New Revision: 438205

URL: http://svn.apache.org/viewvc?rev=438205&view=rev
Log:
Implement handling of several property directories per sitemap
Continue implementation of own web application context for per sitemap contexts

Added:
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonRequestAttributes.java   (with props)
Modified:
    cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/sitemap.xmap
    cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/sitemap.xmap
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/sitemap.xmap
    cocoon/trunk/blocks/cocoon-querybean/cocoon-querybean-sample/src/main/resources/COB-INF/sitemap.xmap
    cocoon/trunk/blocks/cocoon-slide/cocoon-slide-sample/src/main/resources/COB-INF/sitemap.xmap
    cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/davmap/sitemap.xmap
    cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/flowsample/sitemap.xmap
    cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step1/sitemap.xmap
    cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step2/sitemap.xmap
    cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step3/sitemap.xmap
    cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step4/sitemap.xmap
    cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step5/sitemap.xmap
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonWebApplicationContext.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SubSettingsBeanFactoryPostProcessor.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java

Modified: cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/sitemap.xmap?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/modules/sitemap.xmap Tue Aug 29 13:49:26 2006
@@ -23,7 +23,8 @@
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
 
   <!-- =========================== Components ============================== -->
-  <map:components property-dir="properties">
+  <map:components>
+    <map:include-properties dir="properties"/>
     <map:actions>
       <!-- Action to store locale name as cookie. -->
       <map:action name="cookie-locale" src="org.apache.cocoon.acting.LocaleAction">

Modified: cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/sitemap.xmap?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-core-samples-additional/cocoon-core-samples-additional-sample/src/main/resources/COB-INF/sitemap.xmap Tue Aug 29 13:49:26 2006
@@ -21,7 +21,8 @@
 
   <!-- ========================= Components ================================ -->
 
-  <map:components property-dir="properties">
+  <map:components>
+    <map:include-properties dir="properties"/>
     <map:generators default="file">
       <map:generator name="linkstatus" src="org.apache.cocoon.generation.LinkStatusGenerator"/>
       <map:generator name="calendar" src="org.apache.cocoon.generation.CalendarGenerator"/>

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/sitemap.xmap?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/sitemap.xmap Tue Aug 29 13:49:26 2006
@@ -19,7 +19,7 @@
 
   <!-- ========================= Components ================================ -->
 
-  <map:components logger="portal" property-dir="conf/properties">
+  <map:components logger="portal">
     <map:generators default="file">
       <map:generator name="portal" src="org.apache.cocoon.portal.generation.PortalGenerator"/>
     </map:generators>

Modified: cocoon/trunk/blocks/cocoon-querybean/cocoon-querybean-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-querybean/cocoon-querybean-sample/src/main/resources/COB-INF/sitemap.xmap?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-querybean/cocoon-querybean-sample/src/main/resources/COB-INF/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-querybean/cocoon-querybean-sample/src/main/resources/COB-INF/sitemap.xmap Tue Aug 29 13:49:26 2006
@@ -19,7 +19,8 @@
 
 <!-- =========================== Components =================================== -->
 
-	<map:components property-dir="properties">
+	<map:components>
+	    <map:include-properties dir="properties"/>
 		<map:transformers default="xslt">
 			<map:transformer name="i18n" src="org.apache.cocoon.transformation.I18nTransformer">
 				<catalogues default="forms">

Modified: cocoon/trunk/blocks/cocoon-slide/cocoon-slide-sample/src/main/resources/COB-INF/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-slide/cocoon-slide-sample/src/main/resources/COB-INF/sitemap.xmap?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-slide/cocoon-slide-sample/src/main/resources/COB-INF/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-slide/cocoon-slide-sample/src/main/resources/COB-INF/sitemap.xmap Tue Aug 29 13:49:26 2006
@@ -17,7 +17,8 @@
 
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
 
-  <map:components property-dir="properties">
+  <map:components>
+	    <map:include-properties dir="properties"/>
   </map:components>
 
 <!-- ========================== Flowscript ================================= -->

Modified: cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/davmap/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/davmap/sitemap.xmap?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/davmap/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/davmap/sitemap.xmap Tue Aug 29 13:49:26 2006
@@ -18,8 +18,9 @@
 
 <!-- =========================== Components ================================ -->
 
-  <map:components property-dir="properties">
-  
+  <map:components>
+    <map:include-properties dir="properties"/>
+
     <map:generators default="file">
       <map:generator 
         name="traverse" 

Modified: cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/flowsample/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/flowsample/sitemap.xmap?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/flowsample/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/flowsample/sitemap.xmap Tue Aug 29 13:49:26 2006
@@ -15,7 +15,8 @@
   limitations under the License.
 -->
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
-<map:components property-dir="properties">
+<map:components>
+  <map:include-properties dir="properties"/>
   <map:generators default="file">
     <map:generator name="traverse" src="org.apache.cocoon.generation.TraversableGenerator"/>
     <map:generator name="jx" src="org.apache.cocoon.generation.JXTemplateGenerator"/>

Modified: cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step1/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step1/sitemap.xmap?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step1/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step1/sitemap.xmap Tue Aug 29 13:49:26 2006
@@ -16,7 +16,8 @@
 -->
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
 
-<map:components property-dir="properties">
+<map:components>
+  <map:include-properties dir="properties"/>
   <map:generators default="file">
     <map:generator name="traverse" src="org.apache.cocoon.generation.TraversableGenerator"/>
   </map:generators>

Modified: cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step2/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step2/sitemap.xmap?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step2/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step2/sitemap.xmap Tue Aug 29 13:49:26 2006
@@ -16,7 +16,8 @@
 -->
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
 
-<map:components property-dir="properties">
+<map:components>
+  <map:include-properties dir="properties"/>
   <map:generators default="file">
     <map:generator name="traverse" src="org.apache.cocoon.generation.TraversableGenerator"/>
   </map:generators>

Modified: cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step3/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step3/sitemap.xmap?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step3/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step3/sitemap.xmap Tue Aug 29 13:49:26 2006
@@ -16,7 +16,8 @@
 -->
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
 
-<map:components property-dir="properties">
+<map:components>
+  <map:include-properties dir="properties"/>
   <map:generators default="file">
     <map:generator name="traverse" src="org.apache.cocoon.generation.TraversableGenerator"/>
   </map:generators>

Modified: cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step4/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step4/sitemap.xmap?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step4/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step4/sitemap.xmap Tue Aug 29 13:49:26 2006
@@ -16,7 +16,8 @@
 -->
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
 
-<map:components property-dir="properties">
+<map:components>
+  <map:include-properties dir="properties"/>
   <map:generators default="file">
     <map:generator name="traverse" src="org.apache.cocoon.generation.TraversableGenerator"/>
   </map:generators>

Modified: cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step5/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step5/sitemap.xmap?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step5/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-webdav/cocoon-webdav-sample/src/main/resources/COB-INF/step5/sitemap.xmap Tue Aug 29 13:49:26 2006
@@ -16,7 +16,8 @@
 -->
 <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0">
 
-<map:components property-dir="properties">
+<map:components>
+  <map:include-properties dir="properties"/>
   <map:generators default="file">
     <map:generator name="traverse" src="org.apache.cocoon.generation.TraversableGenerator"/>
   </map:generators>

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/components/treeprocessor/sitemap/SitemapLanguage.java Tue Aug 29 13:49:26 2006
@@ -365,6 +365,34 @@
     }
 
     /**
+     * compatibility with 2.1.x - check for global variables in sitemap
+     * TODO - This will be removed in later versions!
+     */
+    protected Properties getGlobalSitemapVariables(Configuration tree)
+    throws ConfigurationException {
+        // compatibility with 2.1.x - check for global variables in sitemap
+        // TODO - This will be removed in later versions!
+        Properties globalSitemapVariables = null;
+        if ( tree.getChild("pipelines").getChild("component-configurations", false) != null ) {
+            Deprecation.logger.warn("The 'component-configurations' section in the sitemap is deprecated. Please check for alternatives.");
+            globalSitemapVariables = new Properties();
+            // now check for global variables - if any other element occurs: throw exception
+            Configuration[] children = tree.getChild("pipelines").getChild("component-configurations").getChildren();
+            for(int i=0; i<children.length; i++) {
+                if ( "global-variables".equals(children[i].getName()) ) {
+                    Configuration[] variables = children[i].getChildren();
+                    for(int v=0; v<variables.length; v++) {
+                        globalSitemapVariables.setProperty(variables[v].getName(), variables[v].getValue());
+                    }
+               } else {
+                    throw new ConfigurationException("Component configurations in the sitemap are not allowed for component: " + children[i].getName());
+                }
+            }
+        }
+        return globalSitemapVariables;
+    }
+
+    /**
      * Build a processing tree from a <code>Configuration</code>.
      */
     public ProcessingNode build(Configuration tree) throws Exception {
@@ -397,28 +425,20 @@
 
         // compatibility with 2.1.x - check for global variables in sitemap
         // TODO - This will be removed in later versions!
-        Properties globalSitemapVariables = null;
-        if ( tree.getChild("pipelines").getChild("component-configurations", false) != null ) {
-            Deprecation.logger.warn("The 'component-configurations' section in the sitemap is deprecated. Please check for alternatives.");
-            globalSitemapVariables = new Properties();
-            // now check for global variables - if any other element occurs: throw exception
-            Configuration[] children = tree.getChild("pipelines").getChild("component-configurations").getChildren();
-            for(int i=0; i<children.length; i++) {
-                if ( "global-variables".equals(children[i].getName()) ) {
-                    Configuration[] variables = children[i].getChildren();
-                    for(int v=0; v<variables.length; v++) {
-                        globalSitemapVariables.setProperty(variables[v].getName(), variables[v].getValue());
-                    }
-               } else {
-                    throw new ConfigurationException("Component configurations in the sitemap are not allowed for component: " + children[i].getName());
-                }
-            }
-        }
+        final Properties globalSitemapVariables = this.getGlobalSitemapVariables(tree);
+
         // check for sitemap local properties
         Settings settings = (Settings)factory.getCurrentBeanFactory(itsContext).getBean(Settings.ROLE);
         if ( componentConfig != null ) {
-            final String propertyDir = componentConfig.getAttribute("property-dir", null);
-            settings = this.createSettings(settings, propertyDir, useDefaultIncludes, factory.getCurrentBeanFactory(itsContext), globalSitemapVariables);
+            List propertyDirs = null;
+            Configuration[] propertyDirConfigs = componentConfig.getChildren("include-properties");
+            if ( propertyDirConfigs.length > 0 ) {
+                propertyDirs = new ArrayList();
+                for(int i=0; i < propertyDirConfigs.length; i++) {
+                    propertyDirs.add(propertyDirConfigs[i].getAttribute("dir"));
+                }
+            }
+            settings = this.createSettings(settings, propertyDirs, useDefaultIncludes, factory.getCurrentBeanFactory(itsContext), globalSitemapVariables);
         } else if ( globalSitemapVariables != null ) {
             MutableSettings s = new MutableSettings(settings);
             PropertyHelper.replaceAll(globalSitemapVariables, settings);
@@ -1152,7 +1172,7 @@
      * @return A new Settings object
      */
     protected MutableSettings createSettings(Settings    parent,
-                                             String      directory,
+                                             List        directories,
                                              boolean     useDefaultIncludes,
                                              BeanFactory parentBeanFactory,
                                              Properties  globalSitemapVariables) {
@@ -1172,12 +1192,16 @@
             SettingsHelper.readProperties(SitemapLanguage.DEFAULT_CONFIG_PROPERTIES + '/' + mode, s, properties, resolver, getLogger());    
         }
 
-        if ( directory != null ) {
+        if ( directories != null ) {
         	SourceResolver resolver = this.processor.getSourceResolver();
-            // now read all properties from the properties directory
-            SettingsHelper.readProperties(directory, s, properties, resolver, getLogger());
-            // read all properties from the mode dependent directory
-            SettingsHelper.readProperties(directory + '/' + mode, s, properties, resolver, getLogger());
+            final Iterator i = directories.iterator();
+            while ( i.hasNext() ) {
+                final String directory = (String)i.next();
+                // now read all properties from the properties directory
+                SettingsHelper.readProperties(directory, s, properties, resolver, getLogger());
+                // read all properties from the mode dependent directory
+                SettingsHelper.readProperties(directory + '/' + mode, s, properties, resolver, getLogger());
+            }
         }
 
         // Next look for a custom property provider in the parent bean factory

Added: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonRequestAttributes.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonRequestAttributes.java?rev=438205&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonRequestAttributes.java (added)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonRequestAttributes.java Tue Aug 29 13:49:26 2006
@@ -0,0 +1,101 @@
+/* 
+ * Copyright 2006 The Apache Software Foundation
+ * Licensed  under the  Apache License,  Version 2.0  (the "License");
+ * you may not use  this file  except in  compliance with the License.
+ * You may obtain a copy of the License at 
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed  under the  License is distributed on an "AS IS" BASIS,
+ * WITHOUT  WARRANTIES OR CONDITIONS  OF ANY KIND, either  express  or
+ * implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.core.container.spring;
+
+import org.apache.cocoon.environment.Request;
+import org.apache.cocoon.environment.Session;
+import org.springframework.web.context.scope.RequestAttributes;
+
+/**
+ * This is an implementation of Springs {@link RequestAttributes} based
+ * on the Cocoon request interface.
+ * Request scope is mapped to Cocoon request scope, session scope to Cocoon's
+ * request global scope and global session scope to session scope!
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public class CocoonRequestAttributes implements RequestAttributes {
+
+    final protected Request request;
+
+    public CocoonRequestAttributes(Request r) {
+        this.request = r;
+    }
+
+    /**
+     * @see org.springframework.web.context.scope.RequestAttributes#getAttribute(java.lang.String, int)
+     */
+    /**
+     * @see org.springframework.web.context.scope.RequestAttributes#getAttribute(java.lang.String, int)
+     */
+    public Object getAttribute(String key, int scope) {
+        if ( scope == RequestAttributes.SCOPE_REQUEST ) {
+            return this.request.getAttribute(key, Request.REQUEST_SCOPE);
+        }
+        if ( scope == RequestAttributes.SCOPE_SESSION ) {
+            return this.request.getAttribute(key, Request.GLOBAL_SCOPE);
+        }
+        final Session session = this.request.getSession(false);
+        if ( session != null ) {
+            return session.getAttribute(key);
+        }
+        return null;
+    }
+
+    /**
+     * @see org.springframework.web.context.scope.RequestAttributes#getSessionMutex()
+     */
+    public Object getSessionMutex() {
+        return this.request.getSession();
+    }
+
+    /**
+     * @see org.springframework.web.context.scope.RequestAttributes#removeAttribute(java.lang.String, int)
+     */
+    public void removeAttribute(String key, int scope) {
+        if ( scope == RequestAttributes.SCOPE_REQUEST ) {
+            this.request.removeAttribute(key, Request.REQUEST_SCOPE);
+        }
+        if ( scope == RequestAttributes.SCOPE_SESSION ) {
+            this.request.removeAttribute(key, Request.GLOBAL_SCOPE);
+        }
+        if ( scope == RequestAttributes.SCOPE_GLOBAL_SESSION ) {
+            final Session session = this.request.getSession(false);
+            if ( session != null ) {
+                session.removeAttribute(key);
+            }
+        }
+    }
+
+    /**
+     * @see org.springframework.web.context.scope.RequestAttributes#setAttribute(java.lang.String, java.lang.Object, int)
+     */
+    public void setAttribute(String key, Object value, int scope) {
+        if ( scope == RequestAttributes.SCOPE_REQUEST ) {
+            this.request.setAttribute(key, value, Request.REQUEST_SCOPE);
+        }
+        if ( scope == RequestAttributes.SCOPE_SESSION ) {
+            this.request.setAttribute(key, value, Request.GLOBAL_SCOPE);
+        }
+        if ( scope == RequestAttributes.SCOPE_GLOBAL_SESSION ) {
+            final Session session = this.request.getSession(true);
+            session.setAttribute(key, value);
+        }
+    }
+
+}

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonRequestAttributes.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonRequestAttributes.java
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonWebApplicationContext.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonWebApplicationContext.java?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonWebApplicationContext.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/CocoonWebApplicationContext.java Tue Aug 29 13:49:26 2006
@@ -16,8 +16,16 @@
  */
 package org.apache.cocoon.core.container.spring;
 
-import org.springframework.context.ApplicationContext;
+import java.util.Stack;
+
+import javax.servlet.ServletContext;
+
 import org.springframework.core.io.Resource;
+import org.springframework.util.ClassUtils;
+import org.springframework.util.ResourceUtils;
+import org.springframework.web.context.WebApplicationContext;
+import org.springframework.web.context.scope.RequestAttributes;
+import org.springframework.web.context.support.WebApplicationContextUtils;
 import org.springframework.web.context.support.XmlWebApplicationContext;
 
 /**
@@ -29,18 +37,83 @@
  */
 public class CocoonWebApplicationContext extends XmlWebApplicationContext {
 
-    protected String baseUrl;
+    private static final String BEAN_FACTORY_STACK_REQUEST_ATTRIBUTE = CocoonWebApplicationContext.class.getName() + "/Stack";
+
+    /** The base url (already postfixed with a '/'). */
+    protected final String baseUrl;
+
+    /** The class loader for this context (or null). */
+    protected final ClassLoader classLoader;
 
-    public CocoonWebApplicationContext(ApplicationContext parent, String url) {
+    public CocoonWebApplicationContext(ClassLoader           classloader,
+                                       WebApplicationContext parent,
+                                       String                url) {
         this.setParent(parent);
-        this.baseUrl = url;
+        if ( url.endsWith("/") ) {
+            this.baseUrl = url;
+        } else {
+            this.baseUrl = url + '/';
+        }
+        this.classLoader = (classloader != null ? classloader : ClassUtils.getDefaultClassLoader());
     }
 
     /**
      * @see org.springframework.web.context.support.AbstractRefreshableWebApplicationContext#getResourceByPath(java.lang.String)
      */
     protected Resource getResourceByPath(String path) {
-        // TODO
+        // only if the path does not start with a "/" and is not a url
+        // we assume it is relative
+        if ( path != null && !path.startsWith("/") && !ResourceUtils.isUrl(path) ) {
+            return super.getResourceByPath(this.baseUrl + path);
+        }
         return super.getResourceByPath(path);
     }
+
+    /**
+     * A child application context has no default configuration.
+     * @see org.springframework.web.context.support.XmlWebApplicationContext#getDefaultConfigLocations()
+     */
+    protected String[] getDefaultConfigLocations() {
+        return null;
+    }
+
+    public Object enteringContext(RequestAttributes attributes) {
+        final ClassLoader oldClassLoader = Thread.currentThread().getContextClassLoader();
+        final Object oldContext = attributes.getAttribute(CocoonBeanFactory.BEAN_FACTORY_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+        if ( oldContext != null ) {
+            Stack stack = (Stack)attributes.getAttribute(BEAN_FACTORY_STACK_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+            if ( stack == null ) {
+                stack = new Stack();
+                attributes.setAttribute(BEAN_FACTORY_STACK_REQUEST_ATTRIBUTE, stack, RequestAttributes.SCOPE_REQUEST);
+            }
+            stack.push(oldContext);
+        }
+        attributes.setAttribute(CocoonBeanFactory.BEAN_FACTORY_REQUEST_ATTRIBUTE, this, RequestAttributes.SCOPE_REQUEST);
+        Thread.currentThread().setContextClassLoader(this.classLoader);
+        return oldClassLoader;
+    }
+
+    public void leavingContext(RequestAttributes attributes, Object handle) {
+        Thread.currentThread().setContextClassLoader((ClassLoader)handle);
+        final Stack stack = (Stack)attributes.getAttribute(BEAN_FACTORY_STACK_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+        if ( stack == null ) {
+            attributes.removeAttribute(CocoonBeanFactory.BEAN_FACTORY_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+        } else {
+            final Object oldContext = stack.pop();
+            attributes.setAttribute(CocoonBeanFactory.BEAN_FACTORY_REQUEST_ATTRIBUTE, oldContext, RequestAttributes.SCOPE_REQUEST);
+            if ( stack.size() == 0 ) {
+                attributes.removeAttribute(BEAN_FACTORY_STACK_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+            }
+        }
+    }
+
+    public static WebApplicationContext getCurrentContext(ServletContext servletContext, RequestAttributes attributes) {
+        WebApplicationContext parentContext = WebApplicationContextUtils.getRequiredWebApplicationContext(servletContext);
+        if (attributes.getAttribute(CocoonBeanFactory.BEAN_FACTORY_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST) != null) {
+            parentContext = (CocoonWebApplicationContext) attributes
+                    .getAttribute(CocoonBeanFactory.BEAN_FACTORY_REQUEST_ATTRIBUTE, RequestAttributes.SCOPE_REQUEST);
+        }
+        return parentContext;
+    }
+
 }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/ConfigReader.java Tue Aug 29 13:49:26 2006
@@ -65,6 +65,9 @@
     /** All component configurations. */
     protected final List componentConfigs = new ArrayList();
 
+    /** Is this the root context? */
+    protected final boolean isRootContext;
+
     public static ConfigurationInfo readConfiguration(String source, AvalonEnvironment env)
     throws Exception {
         final ConfigReader converter = new ConfigReader(env, null, null);
@@ -95,6 +98,7 @@
                          ConfigurationInfo parentInfo,
                          SourceResolver    resolver)
     throws Exception {
+        this.isRootContext = parentInfo == null;
         if ( resolver != null ) {
             this.resolver = resolver;
         } else {
@@ -225,7 +229,8 @@
                 this.handleInclude(contextURI, loadedURIs, componentConfig);
             } else if ( "include-beans".equals(componentName) ) {
                 this.handleBeanInclude(contextURI, componentConfig);
-            } else {
+                // we ignore include-properties if this is a child context
+            } else if ( this.isRootContext || !"include-properties".equals(componentName) ) {
                 // Component declaration, add it to list
                 this.componentConfigs.add(componentConfig);
             }

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SubSettingsBeanFactoryPostProcessor.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SubSettingsBeanFactoryPostProcessor.java?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SubSettingsBeanFactoryPostProcessor.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/SubSettingsBeanFactoryPostProcessor.java Tue Aug 29 13:49:26 2006
@@ -16,8 +16,11 @@
  */
 package org.apache.cocoon.core.container.spring;
 
+import java.util.Iterator;
+import java.util.List;
 import java.util.Properties;
 
+import org.apache.cocoon.configuration.PropertyProvider;
 import org.apache.cocoon.configuration.Settings;
 import org.apache.cocoon.configuration.impl.MutableSettings;
 import org.apache.cocoon.configuration.impl.PropertyHelper;
@@ -35,9 +38,13 @@
 
     private static final String DEFAULT_CONFIG_PROPERTIES = "config/properties";
 
-    private static final String DEFAULT_CONFIG_XCONF  = "config/xconf";
+    protected String sitemapUri;
 
-    private static final String DEFAULT_CONFIG_SPRING = "config/spring";
+    protected List directories;
+
+    protected boolean useDefaultIncludes;
+
+    protected Properties globalSitemapVariables;    
 
     /**
      * Initialize this processor.
@@ -52,30 +59,6 @@
 
         // settings can't be changed anymore
         this.settings.makeReadOnly();
-
-    }
-
-    protected MutableSettings createSettings() {
-        MutableSettings s;
-        Settings parentSettings = null;
-        final Properties globalSitemapVariables = null;
-        if ( this.beanFactory != null && this.beanFactory instanceof HierarchicalBeanFactory
-             && ((HierarchicalBeanFactory)this.beanFactory).getParentBeanFactory() != null ) {
-            parentSettings = (Settings)((HierarchicalBeanFactory)this.beanFactory).getParentBeanFactory().getBean(Settings.ROLE);
-        }
-//        if ( componentConfig != null ) {
-//            final String propertyDir = componentConfig.getAttribute("property-dir", null);
-//            s = this.createSettings(parentSettings, propertyDir, useDefaultIncludes, factory.getCurrentBeanFactory(itsContext), globalSitemapVariables);
-//        } else if ( globalSitemapVariables != null ) {
-            s = new MutableSettings(parentSettings);
-            PropertyHelper.replaceAll(globalSitemapVariables, parentSettings);
-            s.configure(globalSitemapVariables);
-//        }
-        // if no config we just add an empty settings
-        if ( s == null ) {
-            s = new MutableSettings(parentSettings);
-        }
-        return s;
     }
 
     /**
@@ -91,11 +74,9 @@
      *
      * @return A new Settings object
      */
-    protected MutableSettings createSettings(Settings    parent,
-                                             String      directory,
-                                             boolean     useDefaultIncludes,
-                                             BeanFactory parentBeanFactory,
-                                             Properties  globalSitemapVariables) {
+    protected MutableSettings createSettings() {
+        final BeanFactory parentBeanFactory = ((HierarchicalBeanFactory)this.beanFactory).getParentBeanFactory();
+        final Settings parent = (Settings)parentBeanFactory.getBean(Settings.ROLE);
         // get the running mode
         final String mode = parent.getRunningMode();
         // get properties
@@ -111,14 +92,33 @@
             this.readProperties(DEFAULT_CONFIG_PROPERTIES + '/' + mode, properties);    
         }
 
-        if ( directory != null ) {
-            // now read all properties from the properties directory
-            this.readProperties(directory, properties);
-            // read all properties from the mode dependent directory
-            this.readProperties(directory + '/' + mode, properties);
+        if ( directories != null ) {
+            final Iterator i = directories.iterator();
+            while ( i.hasNext() ) {
+                final String directory = (String)i.next();
+                // now read all properties from the properties directory
+                this.readProperties(directory, properties);
+                // read all properties from the mode dependent directory
+                this.readProperties(directory + '/' + mode, properties);
+            }
+        }
+
+        // Next look for a custom property provider in the parent bean factory
+        if (parentBeanFactory != null && parentBeanFactory.containsBean(PropertyProvider.ROLE) ) {
+            try {
+                final PropertyProvider provider = (PropertyProvider)parentBeanFactory.getBean(PropertyProvider.ROLE);
+                final Properties providedProperties = provider.getProperties(s, mode, this.sitemapUri);
+                if ( providedProperties != null ) {
+                    properties.putAll(providedProperties);
+                }
+            } catch (Exception ignore) {
+                this.logger.warn("Unable to get properties from provider.", ignore);
+                this.logger.warn("Continuing initialization.");            
+            }
         }
 
         if ( globalSitemapVariables != null ) {
+            PropertyHelper.replaceAll(globalSitemapVariables, s);
             properties.putAll(globalSitemapVariables);
         }
         PropertyHelper.replaceAll(properties, parent);

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java?rev=438205&r1=438204&r2=438205&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/core/container/spring/avalon/ConfigurationReader.java Tue Aug 29 13:49:26 2006
@@ -57,6 +57,9 @@
     /** All component configurations. */
     protected final List componentConfigs = new ArrayList();
 
+    /** Is this the root context? */
+    protected final boolean isRootContext;
+
     public static ConfigurationInfo readConfiguration(String         source,
                                                       ResourceLoader resourceLoader)
     throws Exception {
@@ -83,8 +86,9 @@
     }
 
     private ConfigurationReader(ConfigurationInfo parentInfo,
-                         ResourceLoader    resourceLoader)
+                                ResourceLoader    resourceLoader)
     throws Exception {
+        this.isRootContext = parentInfo == null;
         if ( resourceLoader != null ) {
             this.resolver = new PathMatchingResourcePatternResolver(resourceLoader);
         } else {
@@ -240,7 +244,8 @@
                 this.handleInclude(contextURI, loadedURIs, componentConfig);
             } else if ( "include-beans".equals(componentName) ) {
                 this.handleBeanInclude(contextURI, componentConfig);
-            } else {
+                // we ignore include-properties if this is a child context
+            } else if ( this.isRootContext || !"include-properties".equals(componentName) ) {
                 // Component declaration, add it to list
                 this.componentConfigs.add(componentConfig);
             }