cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rgo...@apache.org
Subject svn commit: r609282 [1/2] - in /cocoon/trunk: blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/ blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/a/ blocks/cocoon-core-sample/cocoon...
Date Sun, 06 Jan 2008 09:35:50 GMT
Author: rgoers
Date: Sun Jan  6 01:35:48 2008
New Revision: 609282

URL: http://svn.apache.org/viewvc?rev=609282&view=rev
Log:
Created XPathXMLFileModule to fix problems with XMLFileModule. Added getAttributeValue to JXPathHelper and changed all references to getAttribute to use it instead. Moved registration of VariableResolver to BridgeElementParser from SitemapElementParser to make it available to all Avalon components (i.e. input modules).

Added:
    cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/a/
    cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/a/forrestconf.xml
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/XPathXMLFileModule.java
    cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/resources/META-INF/cocoon/spring/cocoon-store-impl-xmlfile.xml
Modified:
    cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/menu.xml
    cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/sitemap.xmap
    cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/META-INF/cocoon/avalon/cocoon-core-main-sample-modules-input.xconf
    cocoon/trunk/blocks/cocoon-taglib/cocoon-taglib-impl/src/main/java/org/apache/cocoon/jxpath/JXPathCocoonContexts.java
    cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/background/BackgroundRequest.java
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/environment/Request.java
    cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/http/HttpRequest.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/changes/changes.xml
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/JXPathMetaModule.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/RequestAttributeModule.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/XMLFileModule.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/changes/changes.xml
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/input/AbstractJXPathModule.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/input/JXPathHelper.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/BridgeElementParser.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/processing/impl/MockProcessInfoProvider.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/test/java/org/apache/cocoon/environment/mock/MockRequest.java
    cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/test/java/org/apache/cocoon/environment/mock/MockRequestAttributes.java
    cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/changes/changes.xml
    cocoon/trunk/core/cocoon-store/cocoon-store-impl/src/main/resources/META-INF/cocoon/properties/cocoon-store-impl.properties

Added: cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/a/forrestconf.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/a/forrestconf.xml?rev=609282&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/a/forrestconf.xml (added)
+++ cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/a/forrestconf.xml Sun Jan  6 01:35:48 2008
@@ -0,0 +1,26 @@
+<?xml version="1.0"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You 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.
+-->
+<!--+
+    | Demo file for XMLFileModule
+    |
+    | SVN $Id: forrestconf.xml 433543 2006-08-22 06:22:54Z crossley $
+    +-->
+<forrestconf version="1.0">
+  <skin>test-site</skin>
+  <base-url>http://localhost:8786/cocoon</base-url>
+</forrestconf>
\ No newline at end of file

Modified: cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/menu.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/menu.xml?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/menu.xml (original)
+++ cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/menu.xml Sun Jan  6 01:35:48 2008
@@ -48,6 +48,7 @@
     <menu-item label="URLEncodeModule" href="url-encode" desc="URLEncode passed parameter"/>
     <menu-item label="URLDecodeModule" href="url-decode" desc="URLDecode passed parameter"/>
     <menu-item label="XMLFileModule" href="xml" desc="XML node values"/>
+    <menu-item label="XPathXMLFileModule" href="xxml?dir=a" desc="XML node values"/>
   </menu>
 
   <menu label="Documentation">

Modified: cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/sitemap.xmap
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/sitemap.xmap?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/sitemap.xmap (original)
+++ cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/COB-INF/modules/sitemap.xmap Sun Jan  6 01:35:48 2008
@@ -249,6 +249,27 @@
         <map:serialize type="xml"/>
       </map:match>
 
+      <map:match pattern="content/xxml.xml">
+        <map:generate type="jx" src="properties.xml">
+          <map:parameter name="myxml:/forrestconf/@version" value="{myxml:/forrestconf/@version}"/>
+          <map:parameter name="myxml:/forrestconf/skin" value="{myxml:/forrestconf/skin}"/>
+          <map:parameter name="myxml:/*/base-url" value="{myxml:/*/base-url}"/>
+          <map:parameter name="a/forestconf/@version" value="{varxml:/forrestconf/@version}"/>
+          <map:parameter name="a/forrestconf/skin" value="{varxml:/forrestconf/skin}"/>
+          <map:parameter name="a/*/base-url" value="{varxml:/*/base-url}"/>
+          <!--
+            <map:parameter name="slashdot-headline" value="{slashdot:/*:RDF/item[1]/title}"/>
+          -->
+        </map:generate>
+        <map:transform src="properties2page.xsl">
+          <map:parameter name="title" value="XML File Input Module (XMLFileModule)"/>
+          <map:parameter name="description" value="XMLFileModule uses an XML file as
+            a data source, with XPath expressions as the key values. In this example,
+            the keys identify nodes in context://samples/modules/forrestconf.xml"/>
+        </map:transform>
+        <map:serialize type="xml"/>
+      </map:match>
+
       <map:match pattern="content/defaults.xml">
         <map:generate type="jx" src="properties.xml">
           <map:parameter name="defaults:skin" value="{defaults:skin}"/>

Modified: cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/META-INF/cocoon/avalon/cocoon-core-main-sample-modules-input.xconf
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/META-INF/cocoon/avalon/cocoon-core-main-sample-modules-input.xconf?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/META-INF/cocoon/avalon/cocoon-core-main-sample-modules-input.xconf (original)
+++ cocoon/trunk/blocks/cocoon-core-sample/cocoon-core-main-sample/src/main/resources/META-INF/cocoon/avalon/cocoon-core-main-sample-modules-input.xconf Sun Jan  6 01:35:48 2008
@@ -20,6 +20,7 @@
   - Define five additional input modules, 'defaults', 'myxml',
   - 'slashdot' 'random-100-to-500' and 'random-5000-to-10000',
   - for the input modules sample.
+  - Define two input modules, xmyxml and varxml for XPathXMLFileModule sample.
   -
   - $Id$
   -->
@@ -35,12 +36,20 @@
     </component-instance>
     <component-instance name="myxml"
                         class="org.apache.cocoon.components.modules.input.XMLFileModule">
-      <file src="context://samples/modules/forrestconf.xml"/>
+      <file src="blockcontext:/cocoon-core-main-sample/modules/forrestconf.xml"/>
     </component-instance>
     <component-instance name="slashdot"
                         class="org.apache.cocoon.components.modules.input.XMLFileModule">
       <file src="http://slashdot.org/slashdot.rss"/>
     </component-instance>
+    <component-instance name="xmyxml"
+                        class="org.apache.cocoon.components.modules.input.XPathXMLFileModule">
+      <file src="blockcontext:/cocoon-core-main-sample/modules/forrestconf.xml"/>
+    </component-instance>
+    <component-instance name="varxml"
+                        class="org.apache.cocoon.components.modules.input.XPathXMLFileModule">
+      <file src="blockcontext:/cocoon-core-main-sample/modules/{request-param:dir}/forrestconf.xml"/>
+    </component-instance>
     <component-instance name="random-100-to-500"
                         class="org.apache.cocoon.components.modules.input.RandomNumberModule">
       <min>100</min>
@@ -52,5 +61,4 @@
       <max>10000</max>
     </component-instance>
   </input-modules>
-  
 </components>

Modified: cocoon/trunk/blocks/cocoon-taglib/cocoon-taglib-impl/src/main/java/org/apache/cocoon/jxpath/JXPathCocoonContexts.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-taglib/cocoon-taglib-impl/src/main/java/org/apache/cocoon/jxpath/JXPathCocoonContexts.java?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-taglib/cocoon-taglib-impl/src/main/java/org/apache/cocoon/jxpath/JXPathCocoonContexts.java (original)
+++ cocoon/trunk/blocks/cocoon-taglib/cocoon-taglib-impl/src/main/java/org/apache/cocoon/jxpath/JXPathCocoonContexts.java Sun Jan  6 01:35:48 2008
@@ -360,17 +360,17 @@
         }
 
         /**
-         * @see org.apache.cocoon.environment.Request#getAttribute(java.lang.String, int)
+         * @see org.apache.cocoon.environment.Request#getLocalAttribute(java.lang.String)
          */
-        public Object getAttribute(String name, int scope) {
-            return this.delegate.getAttribute(name, scope);
+        public Object getLocalAttribute(String name) {
+            return this.delegate.getLocalAttribute(name);
         }
 
         /**
-         * @see org.apache.cocoon.environment.Request#getAttributeNames(int)
+         * @see org.apache.cocoon.environment.Request#getLocalAttributeNames()
          */
-        public Enumeration getAttributeNames(int scope) {
-            return this.delegate.getAttributeNames(scope);
+        public Enumeration getLocalAttributeNames() {
+            return this.delegate.getLocalAttributeNames();
         }
 
         /**
@@ -389,17 +389,17 @@
         }
 
         /**
-         * @see org.apache.cocoon.environment.Request#removeAttribute(java.lang.String, int)
+         * @see org.apache.cocoon.environment.Request#removeLocalAttribute(java.lang.String)
          */
-        public void removeAttribute(String name, int scope) {
-            this.delegate.removeAttribute(name, scope);
+        public void removeLocalAttribute(String name) {
+            this.delegate.removeLocalAttribute(name);
         }
 
         /**
-         * @see org.apache.cocoon.environment.Request#setAttribute(java.lang.String, java.lang.Object, int)
+         * @see org.apache.cocoon.environment.Request#setAttribute(java.lang.String, java.lang.Object)
          */
-        public void setAttribute(String name, Object o, int scope) {
-            this.delegate.setAttribute(name, o, scope);
+        public void setLocalAttribute(String name, Object o) {
+            this.delegate.setAttribute(name, o);
         }
 
         /**

Modified: cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/background/BackgroundRequest.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/background/BackgroundRequest.java?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/background/BackgroundRequest.java (original)
+++ cocoon/trunk/core/cocoon-core/src/main/java/org/apache/cocoon/environment/background/BackgroundRequest.java Sun Jan  6 01:35:48 2008
@@ -29,7 +29,6 @@
 import org.apache.cocoon.Constants;
 import org.apache.cocoon.environment.Cookie;
 import org.apache.cocoon.environment.Environment;
-import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.Session;
 import org.apache.cocoon.environment.impl.AbstractRequest;
 import org.apache.commons.collections.IteratorUtils;
@@ -161,70 +160,56 @@
      * @see org.apache.cocoon.environment.Request#getAttribute(java.lang.String)
      */
     public Object getAttribute(String name) {
-        return this.getAttribute(name, Request.GLOBAL_SCOPE);
+        return this.globalAttributes.get(name);
     }
     
     /* (non-Javadoc)
      * @see org.apache.cocoon.environment.Request#getAttributeNames()
      */
     public Enumeration getAttributeNames() {
-        return this.getAttributeNames(Request.GLOBAL_SCOPE);
+        return IteratorUtils.asEnumeration(this.globalAttributes.keySet().iterator());
     }
     
     /* (non-Javadoc)
      * @see org.apache.cocoon.environment.Request#setAttribute(java.lang.String, java.lang.Object)
      */
     public void setAttribute(String name, Object value) {
-        this.setAttribute(name, value, Request.GLOBAL_SCOPE);
+        this.globalAttributes.put(name, value);
     }
     
     /* (non-Javadoc)
      * @see org.apache.cocoon.environment.Request#removeAttribute(java.lang.String)
      */
     public void removeAttribute(String name) {
-        this.removeAttribute(name, Request.GLOBAL_SCOPE);
+        this.globalAttributes.remove(name);
     }
 
     /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#getAttribute(java.lang.String, int)
+     * @see org.apache.cocoon.environment.Request#getLocalAttribute(java.lang.String)
      */
-    public Object getAttribute(String name, int scope) {
-        if ( scope == Request.REQUEST_SCOPE ) {
+    public Object getLocalAttribute(String name) {
             return this.attributes.get(name);
-        }
-        return this.globalAttributes.get(name);
     }
     
     /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#getAttributeNames(int)
+     * @see org.apache.cocoon.environment.Request#getLocalAttributeNames()
      */
-    public Enumeration getAttributeNames(int scope) {
-        if ( scope == Request.REQUEST_SCOPE ) {
-            return IteratorUtils.asEnumeration(this.attributes.keySet().iterator());
-        }
-        return IteratorUtils.asEnumeration(this.globalAttributes.keySet().iterator());
+    public Enumeration getLocalAttributeNames() {
+        return IteratorUtils.asEnumeration(this.attributes.keySet().iterator());
     }
     
     /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#setAttribute(java.lang.String, java.lang.Object, int)
+     * @see org.apache.cocoon.environment.Request#setLocalAttribute(java.lang.String, java.lang.Object)
      */
-    public void setAttribute(String name, Object value, int scope) {
-        if ( scope == Request.REQUEST_SCOPE ) {
-            this.attributes.put(name, value);
-        } else {
-            this.globalAttributes.put(name, value);
-        }
+    public void setLocalAttribute(String name, Object value) {
+        this.attributes.put(name, value);
     }
     
     /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#removeAttribute(java.lang.String, int)
+     * @see org.apache.cocoon.environment.Request#removeLocalAttribute(java.lang.String)
      */
-    public void removeAttribute(String name, int scope) {
-        if ( scope == Request.REQUEST_SCOPE ) {
-            this.attributes.remove(name);
-        } else {
-            this.globalAttributes.remove(name);
-        }
+    public void removeLocalAttribute(String name) {
+        this.attributes.remove(name);
     }
 
     public String getParameter(String name) {
@@ -454,11 +439,10 @@
      * @see org.apache.cocoon.environment.Request#searchAttribute(java.lang.String)
      */
     public Object searchAttribute(String name) {
-        Object result = this.getAttribute(name, REQUEST_SCOPE);
+        Object result = this.getLocalAttribute(name);
         if ( result == null ) {
-            result = this.getAttribute(name, GLOBAL_SCOPE);
+            result = this.getAttribute(name);
         }
         return result;
     }
-
-}
+}
\ No newline at end of file

Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/environment/Request.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/environment/Request.java?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/environment/Request.java (original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-api/src/main/java/org/apache/cocoon/environment/Request.java Sun Jan  6 01:35:48 2008
@@ -30,14 +30,10 @@
  * Defines an interface to provide client request information .
  *
  * A client can bind an object attribute into a <code>Request</code> by name.
- * The <code>Request</code> interface defines two scopes for storing objects:
- * <ul>
- * <li><code>GLOBAL_SCOPE</code>
- * <li><code>REQUEST_SCOPE</code>
- * </ul>
- * All objects stored in the request using the <code>GLOBAL_SCOPE</code> 
+
+ * All objects stored in the request using the setAttribute method
  * are available to all sub requests and the main request associatiated
- * Objects stored in the request using the <code>REQUEST_SCOPE</code> are
+ * Objects stored in the request using the setLocalAttribute method are
  * only available for the current (sub) request.
  * 
  * @version $Id$
@@ -52,7 +48,7 @@
 
     /**
      * This constant defines the scope of the request attribute to be
-     * private to the current (sub) request. 
+     * private to the current (sub) request.
      * @since 2.2
      */
     public static final int REQUEST_SCOPE = 2;
@@ -98,8 +94,24 @@
     Object getAttribute(String name);
 
     /**
+     * Returns the value of the named attribute from the <code>LOCAL_SCOPE</code>
+     * as an <code>Object</code>, or <code>null</code> if no attribute
+     * of the given name exists.
+     *
+     * @param name        a <code>String</code> specifying the name of
+     *                        the attribute
+     *
+     * @return                an <code>Object</code> containing the value
+     *                        of the attribute, or <code>null</code> if
+     *                        the attribute does not exist
+     *
+     * @since 2.2
+     */
+    Object getLocalAttribute(String name);
+
+    /**
      * Returns an <code>Enumeration</code> containing the
-     * names of the attributes available to this request in the  <code>GLOBAL_SCOPE</code>.
+     * names of the attributes available to this request globally.
      * This method returns an empty <code>Enumeration</code>
      * if the request has no attributes available to it.
      *
@@ -112,6 +124,20 @@
     Enumeration getAttributeNames();
 
     /**
+     * Returns an <code>Enumeration</code> containing the
+     * names of the attributes available to this request locally.
+     * This method returns an empty <code>Enumeration</code>
+     * if the request has no attributes available to it.
+     *
+     *
+     * @return                an <code>Enumeration</code> of strings
+     *                        containing the names
+     *                         of the request's attributes
+     *
+     */
+    Enumeration getLocalAttributeNames();
+
+    /**
      *
      * Stores an attribute in this request in the <code>GLOBAL_SCOPE</code>.
      * Attributes are reset between requests.
@@ -132,10 +158,8 @@
 
     /**
      *
-     * Removes an attribute from this request in the <code>GLOBAL_SCOPE</code>.  
-     * This method is not
-     * generally needed as attributes only persist as long as the request
-     * is being handled.
+     * Stores an attribute in this request locally.
+     * Attributes are reset between requests.
      *
      * <p>Attribute names should follow the same conventions as
      * package names. Names beginning with <code>java.*</code>,
@@ -144,65 +168,18 @@
      *
      *
      * @param name                        a <code>String</code> specifying
-     *                                        the name of the attribute to remove
-     *
-     */
-    void removeAttribute(String name);
-
-    /**
-     * Returns the value of the named attribute from the scope
-     * as an <code>Object</code>, or <code>null</code> if no attribute 
-     * of the given name exists.
-     *
-     * @param name        a <code>String</code> specifying the name of
-     *                        the attribute
-     * @param scope        scope (global or request) of the attribute
-     *
-     * @return                an <code>Object</code> containing the value
-     *                        of the attribute, or <code>null</code> if
-     *                        the attribute does not exist
-     *
-     * @since 2.2
-     */
-    Object getAttribute(String name, int scope);
-
-    /**
-     * Returns the value of the named attribute searching both scopes
-     * as an <code>Object</code>, or <code>null</code> if no attribute 
-     * of the given name exists. This method first searches in the 
-     * request scope and then, if no object is found, in the global scope.
-     *
-     * @param name        a <code>String</code> specifying the name of
-     *                        the attribute
-     *
-     * @return                an <code>Object</code> containing the value
-     *                        of the attribute, or <code>null</code> if
-     *                        the attribute does not exist
-     *
-     * @since 2.2
-     */
-    Object searchAttribute(String name);
-
-    /**
-     * Returns an <code>Enumeration</code> containing the
-     * names of the attributes available to this request in the scope.
-     * This method returns an empty <code>Enumeration</code>
-     * if the request has no attributes available to it.
-     *
-     * @param scope        scope (global or request) of the attribute
+     *                                        the name of the attribute
      *
-     * @return                an <code>Enumeration</code> of strings
-     *                        containing the names
-     *                         of the request's attributes
+     * @param o                                the <code>Object</code> to be stored
      *
-     * @since 2.2
      */
-    Enumeration getAttributeNames(int scope);
+    void setLocalAttribute(String name, Object o);
 
     /**
      *
-     * Stores an attribute in this request in the scope.
-     * Attributes are reset between requests.
+     * Removes an attribute from this request globally.
+     * This method is not generally needed as attributes only persist as long
+     * as the request is being handled.
      *
      * <p>Attribute names should follow the same conventions as
      * package names. Names beginning with <code>java.*</code>,
@@ -211,16 +188,14 @@
      *
      *
      * @param name                        a <code>String</code> specifying
-     *                                    the name of the attribute    
-     * @param o                            the <code>Object</code> to be stored
-     * @param scope        scope (global or request) of the attribute
+     *                                        the name of the attribute to remove
      *
-     * @since 2.2
      */
-    void setAttribute(String name, Object o, int scope);
+    void removeAttribute(String name);
 
     /**
-     * Removes an attribute from this request in the scope.  
+     *
+     * Removes an attribute from this request in the <code>GLOBAL_SCOPE</code>.
      * This method is not
      * generally needed as attributes only persist as long as the request
      * is being handled.
@@ -233,11 +208,26 @@
      *
      * @param name                        a <code>String</code> specifying
      *                                        the name of the attribute to remove
-     * @param scope        scope (global or request) of the attribute
+     *
+     */
+    void removeLocalAttribute(String name);
+
+    /**
+     * Returns the value of the named attribute searching both scopes
+     * as an <code>Object</code>, or <code>null</code> if no attribute 
+     * of the given name exists. This method first searches in the 
+     * request scope and then, if no object is found, in the global scope.
+     *
+     * @param name        a <code>String</code> specifying the name of
+     *                        the attribute
+     *
+     * @return                an <code>Object</code> containing the value
+     *                        of the attribute, or <code>null</code> if
+     *                        the attribute does not exist
      *
      * @since 2.2
      */
-    void removeAttribute(String name, int scope);
+    Object searchAttribute(String name);
 
     /**
      * Utility method for getting a <code>Map</code> view of the request attributes.

Modified: cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/http/HttpRequest.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/http/HttpRequest.java?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/http/HttpRequest.java (original)
+++ cocoon/trunk/core/cocoon-pipeline/cocoon-pipeline-impl/src/main/java/org/apache/cocoon/environment/http/HttpRequest.java Sun Jan  6 01:35:48 2008
@@ -32,7 +32,6 @@
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.cocoon.environment.Cookie;
-import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.Session;
 import org.apache.cocoon.environment.ValueHolder;
 import org.apache.cocoon.environment.impl.AbstractRequest;
@@ -67,6 +66,8 @@
 
     /**
      * Creates a HttpRequest based on a real HttpServletRequest object
+     * @param req The HttpServletReqeust
+     * @param env The HttpEnvironment
      */
     protected HttpRequest(HttpServletRequest req, HttpEnvironment env) {
         super();
@@ -324,70 +325,56 @@
      * @see org.apache.cocoon.environment.Request#getAttribute(java.lang.String)
      */
     public Object getAttribute(String name) {
-        return this.getAttribute(name, Request.GLOBAL_SCOPE);
+        return this.req.getAttribute(name);
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.environment.Request#getAttributeNames()
      */
     public Enumeration getAttributeNames() {
-        return this.getAttributeNames(Request.GLOBAL_SCOPE);
+        return this.req.getAttributeNames();
     }
     
     /* (non-Javadoc)
      * @see org.apache.cocoon.environment.Request#setAttribute(java.lang.String, java.lang.Object)
      */
     public void setAttribute(String name, Object value) {
-        this.setAttribute(name, value, Request.GLOBAL_SCOPE);
+        this.req.setAttribute(name, value);
     }
 
     /* (non-Javadoc)
      * @see org.apache.cocoon.environment.Request#removeAttribute(java.lang.String)
      */
     public void removeAttribute(String name) {
-        this.removeAttribute(name, Request.GLOBAL_SCOPE);
+        this.req.removeAttribute(name);
     }
 
     /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#getAttribute(java.lang.String, int)
+     * @see org.apache.cocoon.environment.Request#getLocalAttribute(java.lang.String)
      */
-    public Object getAttribute(String name, int scope) {
-        if ( scope == Request.REQUEST_SCOPE ) {
-            return this.attributes.get(name);
-        }
-        return this.req.getAttribute(name);
+    public Object getLocalAttribute(String name) {
+        return this.attributes.get(name);
     }
 
     /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#getAttributeNames(int)
+     * @see org.apache.cocoon.environment.Request#getLocalAttributeNames()
      */
-    public Enumeration getAttributeNames(int scope) {
-        if ( scope == Request.REQUEST_SCOPE ) {
-            return IteratorUtils.asEnumeration(this.attributes.keySet().iterator());
-        }
-        return this.req.getAttributeNames();
+    public Enumeration getLocalAttributeNames() {
+        return IteratorUtils.asEnumeration(this.attributes.keySet().iterator());
     }
 
     /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#setAttribute(java.lang.String, java.lang.Object, int)
+     * @see org.apache.cocoon.environment.Request#setLocalAttribute(java.lang.String, java.lang.Object)
      */
-    public void setAttribute(String name, Object value, int scope) {
-        if ( scope == Request.REQUEST_SCOPE ) {
-            this.attributes.put(name, value);
-        } else {
-            this.req.setAttribute(name, value);
-        }
+    public void setLocalAttribute(String name, Object value) {
+        this.attributes.put(name, value);
     }
 
     /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#removeAttribute(java.lang.String, int)
+     * @see org.apache.cocoon.environment.Request#removeLocalAttribute(java.lang.String)
      */
-    public void removeAttribute(String name, int scope) {
-        if ( scope == Request.REQUEST_SCOPE ) {
-            this.attributes.remove(name);
-        } else {
-            this.req.removeAttribute(name);
-        }
+    public void removeLocalAttribute(String name) {
+        this.attributes.remove(name);
     }
 
     public String getCharacterEncoding() {
@@ -404,6 +391,7 @@
 
     /**
      * Sets the default encoding of the servlet container.
+     * @param container_encoding The default form encoding of the servlet container.
      */
     public void setContainerEncoding(String container_encoding) {
         this.container_encoding = container_encoding;
@@ -518,9 +506,9 @@
      * @see org.apache.cocoon.environment.Request#searchAttribute(java.lang.String)
      */
     public Object searchAttribute(String name) {
-        Object result = this.getAttribute(name, REQUEST_SCOPE);
+        Object result = this.getLocalAttribute(name);
         if ( result == null ) {
-            result = this.getAttribute(name, GLOBAL_SCOPE);
+            result = this.getAttribute(name);
         }
         return result;
     }

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/changes/changes.xml?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/changes/changes.xml (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/changes/changes.xml Sun Jan  6 01:35:48 2008
@@ -24,7 +24,11 @@
     +-->
     <document>
       <body>
-        <release version="1.0.0-RC2" date="2007-??-??" description="unreleased">  
+        <release version="1.0.0-RC2" date="2007-??-??" description="unreleased">
+          <action dev="rgoers" type="fix" issue="COCOON-1574">
+            Created XPathXMLFileModule to fix problems with XMLFileModule. Added getAttributeValue to JXPathHelper
+            and changed all references to getAttribute to use it instead.
+          </action>
           <action dev="gkossakowski" type="add" due-to="Alexander Klimetschek" due-to-email="alexander.klimetschek@mindquarry.com" issue="COCOON-2054">
             StatusGenerator must now show default Store explicitly (because no longer part of StoreJanitor)
           </action>  

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/JXPathMetaModule.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/JXPathMetaModule.java?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/JXPathMetaModule.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/JXPathMetaModule.java Sun Jan  6 01:35:48 2008
@@ -127,7 +127,7 @@
         if (modeConf != null) {
             name = modeConf.getChild("parameter").getValue(!this.parameter.equals("") ? this.parameter : name);
         }
-        return JXPathHelper.getAttribute(name, modeConf, this.configuration, contextObj);
+        return JXPathHelper.getAttributeValue(name, modeConf, this.configuration, contextObj);
     }
 
     /**
@@ -157,6 +157,7 @@
      * @param modeConf a <code>Configuration</code> value
      * @param objectModel a <code>Map</code> value
      * @return an <code>Object</code> value
+     * @throws ConfigurationException from called components.
      */
     protected  Object getContextObject(Configuration modeConf, Map objectModel)
     throws ConfigurationException {

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/RequestAttributeModule.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/RequestAttributeModule.java?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/RequestAttributeModule.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/RequestAttributeModule.java Sun Jan  6 01:35:48 2008
@@ -50,7 +50,8 @@
             // preferred
             pname = modeConf.getChild("parameter").getValue(pname);
         }
-        return ObjectModelHelper.getRequest(objectModel).getAttribute( pname, scope );        
+        Request req = ObjectModelHelper.getRequest(objectModel);
+        return (scope == Request.GLOBAL_SCOPE) ? req.getAttribute(pname) : req.getLocalAttribute(pname);       
     }
     
     /* (non-Javadoc)
@@ -58,7 +59,7 @@
      */
     public Object getAttribute( String name, Configuration modeConf, Map objectModel )
     throws ConfigurationException {
-        return this.getAttribute(name, modeConf, objectModel, Request.GLOBAL_SCOPE);
+        return ObjectModelHelper.getRequest(objectModel).getAttribute(name);
     }
 
 
@@ -98,7 +99,8 @@
                 suffix = "";
             }
             SortedSet names = new TreeSet();
-            Enumeration allNames = request.getAttributeNames( scope );
+            Enumeration allNames = (scope == Request.GLOBAL_SCOPE) ?
+                    request.getAttributeNames() : request.getLocalAttributeNames();
 
             while (allNames.hasMoreElements()) {
                 String pname = (String) allNames.nextElement();
@@ -120,7 +122,8 @@
             // no "*" in attribute name => just return all values of
             // this one attribute. Make sure, it's an array.
 
-            Object value = request.getAttribute( wildcard, scope );
+            Object value = (scope == Request.GLOBAL_SCOPE) ? request.getAttribute( wildcard) :
+                    request.getLocalAttribute( wildcard);
             if ( value != null && !value.getClass().isArray() ) {
                 Object[] values = new Object[1];
                 values[0] = value;

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/XMLFileModule.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/XMLFileModule.java?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/XMLFileModule.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/XMLFileModule.java Sun Jan  6 01:35:48 2008
@@ -419,7 +419,7 @@
             if (getValues){
                 result = JXPathHelper.getAttributeValues(name, modeConf, this.configuration, contextObj);
             } else {
-                result = JXPathHelper.getAttribute(name, modeConf, this.configuration, contextObj);
+                result = JXPathHelper.getAttributeValue(name, modeConf, this.configuration, contextObj);
             }
             if (this.cacheExpressions) {
                 cache.put(name, result);

Added: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/XPathXMLFileModule.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/XPathXMLFileModule.java?rev=609282&view=auto
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/XPathXMLFileModule.java (added)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-components/src/main/java/org/apache/cocoon/components/modules/input/XPathXMLFileModule.java Sun Jan  6 01:35:48 2008
@@ -0,0 +1,515 @@
+package org.apache.cocoon.components.modules.input;
+
+import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.Serviceable;
+import org.apache.avalon.framework.thread.ThreadSafe;
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.excalibur.source.SourceResolver;
+import org.apache.excalibur.source.SourceValidity;
+import org.apache.excalibur.source.Source;
+import org.apache.excalibur.store.Store;
+import org.apache.cocoon.components.source.util.SourceUtil;
+import org.apache.cocoon.components.treeprocessor.variables.VariableResolverFactory;
+import org.apache.cocoon.components.treeprocessor.variables.VariableResolver;
+
+import org.apache.cocoon.sitemap.PatternException;
+import org.apache.cocoon.ProcessingException;
+import org.apache.commons.collections.map.ReferenceMap;
+import org.apache.commons.collections.map.AbstractReferenceMap;
+import org.w3c.dom.Document;
+import org.xml.sax.SAXException;
+
+import java.util.Map;
+import java.net.MalformedURLException;
+import java.io.IOException;
+
+/**
+ * <grammar>
+ *   <define name="input.module.config.contents" combine="choice">
+ *     <optional><element name="cacheable"><data type="boolean"/></element></optional>
+ *     <optional><element name="reloadable"><data type="boolean"/></element></optional>
+ *     <optional>
+ *       <ref name="org.apache.cocoon.components.modules.input.XPathXMLFileModule:file">
+ *     </optional>
+ *     <optional><element name="cache-role"><data type="String"/></element></optional>
+ *   </define>
+ * <p/>
+ *   <define name="input.module.runtime.contents" combine="choice">
+ *     <optional>
+ *       <ref name="org.apache.cocoon.components.modules.input.XPathXMLFileModule:file">
+ *     </optional>
+ *   </define>
+ * <p/>
+ *   <define name="org.apache.cocoon.components.modules.input.XPathXMLFileModule:file">
+ *     <element name="file">
+ *       <attribute name="src"><data type="anyURI"/></attribute>
+ *       <optional><attribute name="cacheable"><data type="boolean"/></attribute></optional>
+ *       <optional><attribute name="reloadable"><data type="boolean"/></attribute></optional>
+ *     </element>
+ *   </define>
+ * </grammar>
+ * <p/>
+ * This module provides an Input Module interface to any XML document, by using
+ * XPath expressions as attribute keys.
+ * The XML can be obtained from any Cocoon <code>Source</code> (e.g.,
+ * <code>cocoon:/...</code>, <code>context://..</code>, and regular URLs).
+ * Sources can be cached in memory for better performance and reloaded if
+ * changed. The source can also contain references to other input modules to allow the source
+ * file name to be determined dynamically.
+ * <p/>
+ * Caching and reloading can be turned on / off (default: caching on,
+ * reloading off) through <code>&lt;reloadable&gt;false&lt;/reloadable&gt;</code>
+ * and <code>&lt;cacheable&gt;false&lt;/cacheable&gt;</code>. The file
+ * (source) to use is specified through <code>&lt;file
+ * src="protocol:path/to/file.xml" reloadable="true" cacheable="true"/&gt;</code>
+ * optionally overriding the defaults for caching and/or reloading. When specfied as attributes
+ * to the file element the values for cacheable and reloadable may be input module references which
+ * will be resolved on every call. These must resolve to 'true' or 'false'.
+ * </>
+ * The XML documents will be cached using the Store configured via the cache-role configuration
+ * element. If not specified the default Store as specified in this classes ROLE attribute will
+ * be used.
+ * <p/>
+ * In addition, xpath expressions can be cached for higher performance.
+ * Thus, if an expression has been evaluated for a file, the result
+ * is cached and will be reused, the expression is not evaluated
+ * a second time. This can be turned off using the <code>cache-expressions</code>
+ * configuration option.
+ *
+ * @version $Id: $
+ */
+public class XPathXMLFileModule extends AbstractInputModule
+    implements Serviceable, ThreadSafe
+{
+    public static final String ROLE = Store.ROLE + "/XPathXMLFileTransientStore";
+    /**
+     * Contains all globally registered extension classes and
+     * packages. Thus the lookup and loading of globally registered
+     * extensions is done only once.
+     */
+    protected JXPathHelperConfiguration configuration;
+
+    /**
+     * Static (cocoon.xconf) configuration location, for error reporting
+     */
+    String staticConfLocation;
+
+    /**
+     * Cached documents
+     */
+    private Store cache;
+
+    /**
+     * Determines whether the configured source document should be cached.
+     */
+    private String  cacheParm;
+    private Boolean cacheSource;
+
+    /**
+     * Determines whether the configured source document should be reloaded.
+     */
+    private String  reloadParm;
+    private Boolean reloadSource;
+
+    /**
+     * Default value for reloadability of sources. Defaults to false.
+     */
+    boolean reloadAll;
+    /**
+     * Default value for cacheability of xpath expressions. Defaults to true.
+     */
+    private boolean cacheExpressions;
+
+    /**
+     *  Whether the source needs to be resolved.
+     */
+    private boolean needsResolve;
+
+    /**
+     * Overrides attribute name
+     */
+    protected String parameter;
+
+    /**
+     * Default src
+     */
+    private String src;
+
+    protected SourceResolver resolver;
+    protected ServiceManager manager;
+
+
+    /* (non-Javadoc)
+    * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+    */
+    public void service(ServiceManager manager) throws ServiceException {
+        this.manager = manager;
+        this.resolver = (SourceResolver) manager.lookup(SourceResolver.ROLE);
+    }
+
+    /**
+     * Static (cocoon.xconf) configuration.
+     * Configuration is expected to be of the form:
+     * &lt;...&gt;
+     * &lt;reloadable&gt;<b>true</b>|false&lt;/reloadable&gt;
+     * &lt;cacheable&gt;<b>true</b>|false&lt;/cacheable&gt;
+     * &lt;cache-role&gt;org.apache.excalibur.store.Store/TransientStore&lt;/cache-role&gt;
+     * &lt;file src="<i>src</i>"/&gt;
+     * ...
+     * &lt;/...&gt;
+     * <p/>
+     * The &lt;file/&gt; element specifies a file pattern. Only one
+     * &lt;file&gt; can be specified, however it can contain references to input modules which will be resolved
+     * each time the module is used. The configured <i>src</i> is used if not
+     * overridden via a file parameter in the sitemap.
+     *
+     * @param config a <code>Configuration</code> value, as described above.
+     * @throws org.apache.avalon.framework.configuration.ConfigurationException
+     *          if an error occurs
+     */
+    public void configure(Configuration config) throws ConfigurationException {
+        this.configuration = JXPathHelper.setup(config);
+        this.staticConfLocation = config.getLocation();
+        Configuration roleConfig = config.getChild("cache-role", true);
+        boolean cacheAll = config.getChild("cacheable").getValueAsBoolean(true);
+        this.reloadAll = config.getChild("reloadable").getValueAsBoolean(true);
+        String cacheRole = roleConfig.getValue(ROLE);
+
+        if (getLogger().isDebugEnabled()) {
+            getLogger().debug("Using cache " + cacheRole);
+        }
+
+        try {
+            this.cache = (Store) this.manager.lookup(cacheRole);
+        } catch (ServiceException ce) {
+            throw new ConfigurationException("Unable to lookup cache: " + cacheRole, ce);
+        }
+
+        Configuration fileConfig = config.getChild("file");
+
+        this.src = fileConfig.getAttribute("src");
+        this.cacheParm = fileConfig.getAttribute("cacheable", null);
+        this.reloadParm = fileConfig.getAttribute("reloadable", null);
+        if (this.cacheParm == null) {
+            this.cacheSource = Boolean.valueOf(cacheAll);
+        } else if (VariableResolverFactory.needsResolve(this.cacheParm)) {
+            this.cacheSource = null;
+        } else {
+            this.cacheSource = Boolean.valueOf(this.cacheParm);
+        }
+        if (this.reloadParm == null) {
+            this.reloadSource = Boolean.valueOf(this.reloadAll);
+        } else if (VariableResolverFactory.needsResolve(this.reloadParm)) {
+            this.reloadSource = null;
+        } else {
+            this.reloadSource = Boolean.valueOf(this.reloadParm);
+        }
+
+        // init caches
+        this.cacheExpressions = config.getChild("cache-expressions").getValueAsBoolean(true);
+        this.needsResolve = VariableResolverFactory.needsResolve(this.src);
+    }
+
+    /**
+     * Dispose this component
+     */
+    public void dispose() {
+        super.dispose();
+        if (this.manager != null) {
+            this.manager.release(this.resolver);
+            this.manager.release(this.cache);
+            this.resolver = null;
+            this.cache = null;
+            this.manager = null;
+        }
+    }
+
+    public Object getAttribute(String name, Configuration modeConf, Map objectModel)
+        throws ConfigurationException {
+        return getAttribute(name, modeConf, objectModel, false);
+    }
+
+    public Object[] getAttributeValues(String name, Configuration modeConf, Map objectModel)
+        throws ConfigurationException {
+        Object result = getAttribute(name, modeConf, objectModel, true);
+        return (result != null ? (Object[]) result : null);
+    }
+    /**
+     * Get the DocumentInfo for the DOM object that JXPath will operate on when evaluating
+     * attributes.  This DOM is loaded from a Source, specified in the
+     * modeConf, or (if modeConf is null) from the
+     * {@link #configure(org.apache.avalon.framework.configuration.Configuration)}.
+     *
+     * @param name The JXPath to retrieve
+     * @param modeConf    The dynamic configuration for the current operation. May
+     *                    be <code>null</code>, in which case static (cocoon.xconf) configuration
+     *                    is used.  Configuration is expected to have a &lt;file> child node, and
+     *                    be of the form:
+     *                    &lt;...&gt;
+     *                    &lt;file src="..." reloadable="true|false"/&gt;
+     *                    &lt;/...&gt;
+     * @param objectModel Object Model for the current module operation.
+     * @param getValues true if multiple values should be retrieve, false otherwise
+     * @return the result of the XPath query into the XML document
+     * @throws ConfigurationException if an error occurs.
+     */
+    private Object getAttribute(String name, Configuration modeConf, Map objectModel, boolean getValues)
+        throws ConfigurationException {
+
+        if (modeConf != null) {
+            name = modeConf.getChild("parameter").getValue(this.parameter != null ? this.parameter : name);
+        }
+
+        boolean hasDynamicConf = false; // whether we have a <file src="..."> dynamic configuration
+        Configuration fileConf = null;  // the nested <file>, if any
+
+        if (modeConf != null && modeConf.getChildren().length > 0) {
+            fileConf = modeConf.getChild("file", false);
+            if (fileConf == null) {
+                if (getLogger().isDebugEnabled()) {
+                    getLogger().debug("Missing 'file' child element at " + modeConf.getLocation());
+                }
+            } else {
+                hasDynamicConf = true;
+            }
+        }
+
+        String src = this.src;
+        Boolean cacheSource = this.cacheSource;
+        Boolean reloadSource = this.cacheSource;
+        boolean needsResolve = this.needsResolve;
+        String cacheParm = this.cacheParm;
+        String reloadParm = this.reloadParm;
+
+        if (hasDynamicConf) {
+            src = fileConf.getAttribute("src");
+            cacheParm = fileConf.getAttribute("cacheable", this.cacheParm);
+            reloadParm = fileConf.getAttribute("reloadable", this.reloadParm);
+            if (cacheParm == null) {
+                cacheSource = this.cacheSource;
+            } else if (VariableResolverFactory.needsResolve(cacheParm)) {
+                cacheSource = null;
+                if (cacheSource == null) {
+                    try {
+                        VariableResolver varResolver = VariableResolverFactory.getResolver(cacheParm, this.manager);
+                        cacheSource = Boolean.valueOf(varResolver.resolve(objectModel));
+                    } catch (PatternException pe) {
+                        throw new ConfigurationException("Unable to resolve " + cacheParm, pe);
+                    }
+                }
+            } else {
+                cacheSource = Boolean.valueOf(cacheParm);
+            }
+            if (reloadParm == null) {
+                reloadSource = this.reloadSource;
+            } else if (VariableResolverFactory.needsResolve(reloadParm)) {
+                reloadSource = null;
+            } else {
+                reloadSource = Boolean.valueOf(reloadParm);
+            }
+            needsResolve = true;
+        }
+        if (cacheSource == null) {
+            try {
+                VariableResolver varResolver = VariableResolverFactory.getResolver(cacheParm, this.manager);
+                cacheSource = Boolean.valueOf(varResolver.resolve(objectModel));
+            } catch (PatternException pe) {
+                throw new ConfigurationException("Unable to resolve " + cacheParm, pe);
+            }
+        }
+        if (reloadSource == null) {
+            try {
+                VariableResolver varResolver =
+                    VariableResolverFactory.getResolver(reloadParm, this.manager);
+                reloadSource = Boolean.valueOf(varResolver.resolve(objectModel));
+            } catch (PatternException pe) {
+                throw new ConfigurationException("Unable to resolve " + reloadParm, pe);
+            }
+        }
+
+        if (src == null) {
+            throw new ConfigurationException(
+                "No source specified"
+                    + (modeConf != null ? ", either dynamically in " + modeConf.getLocation() + ", or " : "")
+                    + " statically in "
+                    + staticConfLocation);
+        }
+
+        if (needsResolve) {
+            try {
+                VariableResolver varResolver = VariableResolverFactory.getResolver(src, this.manager);
+                src = varResolver.resolve(objectModel);
+            } catch (PatternException pe) {
+                throw new ConfigurationException("Error resolving variables for " + src, pe);
+            }
+        }
+
+        Object result;
+
+        if (cacheSource.booleanValue()) {
+            DocumentInfo info = (DocumentInfo) this.cache.get(src);
+            if (info == null || (reloadSource.booleanValue() && !info.isValid())) {
+                Source docSource = null;
+                try {
+                    docSource = resolver.resolveURI(src);
+                    DocumentInfo newInfo =  new DocumentInfo(src, SourceUtil.toDOM(this.manager, docSource),
+                        docSource.getValidity(), this.cacheExpressions, this.resolver);
+                    synchronized(this.cache) {
+                        DocumentInfo cachedInfo = (DocumentInfo)this.cache.get(src);
+                        if (cachedInfo == null || cachedInfo == info) {
+                            this.cache.store(src, newInfo);
+                            info = newInfo;
+                        } else {
+                            info = cachedInfo;
+                        }
+                    }
+                } catch (MalformedURLException mue) {
+                    throw new ConfigurationException("Unable to resolve " + src, mue);
+                } catch (IOException ioe) {
+                    throw new ConfigurationException("Unable to access" + src, ioe);
+                } catch (ProcessingException pe) {
+                    throw new ConfigurationException("Unable to process " + src, pe);
+                } catch (SAXException se) {
+                    throw new ConfigurationException("Error processing XML document " + src, se);
+                } finally {
+                    if (docSource != null) {
+                        resolver.release(docSource);
+                    }
+                }
+            }
+            if (info.cacheExpressions) {
+                Map cache = getValues ? info.expressionValuesCache : info.expressionCache;
+                synchronized (cache) {
+                    if (cache.containsKey(name)) {
+                        result = cache.get(name);
+                        if (getLogger().isDebugEnabled()) {
+                            getLogger().debug("for " + name + " using cached result " + result);
+                        }
+                    } else {
+                        result = getResult(name, info.document, modeConf, getValues);
+                        if (result != null) {
+                            cache.put(name, result);
+                            if (getLogger().isDebugEnabled()) {
+                                getLogger().debug("for " + name + " newly caching result " + result);
+                            }
+                        } else {
+                            if (getLogger().isDebugEnabled()) {
+                                getLogger().debug("for " + name + " result is null");
+                            }
+                        }
+                    }
+                }
+            } else {
+                result = getResult(name, info.document, modeConf, getValues);
+                if (getLogger().isDebugEnabled()) {
+                    getLogger().debug("for " + name + " result is " + result);
+                }
+            }
+        } else {
+            Source docSource = null;
+            try {
+                docSource = resolver.resolveURI(src);
+                result = getResult(name, SourceUtil.toDOM(this.manager, docSource), modeConf, getValues);
+                if (getLogger().isDebugEnabled()) {
+                    getLogger().debug("for " + name + " result is " + result);
+                }
+            } catch (MalformedURLException mue) {
+                throw new ConfigurationException("Unable to resolve " + src, mue);
+            } catch (IOException ioe) {
+                throw new ConfigurationException("Unable to access" + src, ioe);
+            } catch (ProcessingException pe) {
+                throw new ConfigurationException("Unable to process " + src, pe);
+            } catch (SAXException se) {
+                throw new ConfigurationException("Error processing XML document " + src, se);
+            } finally {
+                if (docSource != null) {
+                    resolver.release(docSource);
+                }
+            }
+        }
+
+        return result;
+    }
+
+    private Object getResult(String name, Document document, Configuration modeConf, boolean getValues)
+        throws ConfigurationException {
+        Object result;
+
+        if (getValues) {
+            result = JXPathHelper.getAttributeValues(name, modeConf, this.configuration, document);
+        } else {
+            result = JXPathHelper.getAttributeValue(name, modeConf, this.configuration, document);
+        }
+        return result;
+    }
+
+    /**
+     * Used to keep track of the Document, its validity and any cached expressions.
+     */
+    private static class DocumentInfo
+    {
+        public DocumentInfo(String uri, Document doc, SourceValidity validity, boolean cacheExpressions,
+                            SourceResolver resolver) {
+            this.cacheExpressions = cacheExpressions;
+            if (cacheExpressions) {
+                expressionCache = new ReferenceMap(AbstractReferenceMap.SOFT, AbstractReferenceMap.SOFT);
+                expressionValuesCache = new ReferenceMap(AbstractReferenceMap.SOFT, AbstractReferenceMap.SOFT);
+            }
+            this.resolver = resolver;
+            this.uri = uri;
+            this.document = doc;
+            this.validity = validity;
+        }
+
+        private boolean cacheExpressions;
+
+        private final String uri;
+
+        private final SourceValidity validity;
+
+        private final SourceResolver resolver;
+
+        /**
+         * Source content cached as DOM Document
+         */
+        private final Document document;
+
+        private Map expressionCache;
+        private Map expressionValuesCache;
+
+        /**
+         * Returns true if the document is valid, false otherwise.
+         * <p/>
+         *
+         * @return returns true if the document is valid, false otherwise.
+         */
+        private boolean isValid() {
+            Source src = null;
+            boolean result = true;
+
+            try {
+                int valid = validity == null ? SourceValidity.INVALID : validity.isValid();
+                if (valid == SourceValidity.UNKNOWN) {
+                    // Get new source and validity
+                    src = resolver.resolveURI(this.uri);
+                    SourceValidity newValidity = src.getValidity();
+                    valid = validity.isValid(newValidity);
+                }
+                if (valid != SourceValidity.VALID) {
+                    result = false;
+                }
+            }
+            catch (Exception ex) {
+                result = false;
+            }
+            finally {
+                if (src != null) {
+                    resolver.release(src);
+                }
+            }
+            return result;
+        }
+    }
+}
\ No newline at end of file

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/changes/changes.xml?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/changes/changes.xml (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/changes/changes.xml Sun Jan  6 01:35:48 2008
@@ -26,6 +26,10 @@
 <document>
   <body>
     <release version="1.0.0" date="2008-??-??" description="unreleased">
+      <action dev="rgoers" type="fix">
+        Moved registration of VariableResolver to BridgeElementParser from SitemapElementParser to make it
+        available to all Avalon components (i.e. input modules).
+      </action>
       <action dev="vgritsenko" type="remove">
         Remove support for Cocoon 2.0 error handlers, &lt;map:handle-errors type="500"&gt;,
         which were deprecated since Cocoon 2.1m1.

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/input/AbstractJXPathModule.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/input/AbstractJXPathModule.java?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/input/AbstractJXPathModule.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/input/AbstractJXPathModule.java Sun Jan  6 01:35:48 2008
@@ -102,7 +102,7 @@
         if (modeConf != null) {
             name = modeConf.getChild("parameter").getValue(this.parameter != null ? this.parameter : name);
         }
-        return JXPathHelper.getAttribute(name, modeConf, this.configuration, contextObj);
+        return JXPathHelper.getAttributeValue(name, modeConf, this.configuration, contextObj);
     }
 
 
@@ -134,6 +134,10 @@
      * Descendants should override this method to return a specific object
      * that is requried by the implementing class.
      * Examples are: request, session and application context objects.
+     * @param modeConf The Configuration.
+     * @param objectModel Cocoon's object model Map.
+     * @return The context object.
+     * @throws ConfigurationException when an error occurs.
      */
     protected abstract Object getContextObject(Configuration modeConf,
                                                Map objectModel)

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/input/JXPathHelper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/input/JXPathHelper.java?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/input/JXPathHelper.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/components/modules/input/JXPathHelper.java Sun Jan  6 01:35:48 2008
@@ -44,7 +44,8 @@
      * This method used in both AbstractJXPathModule and JXPathMetaModule
      * to configure JXPath.
      *
-     * @param config a <code>Configuration</code> value
+     * @param config a <code>Configuration</code> value.
+     * @return The JXPathHelperConfiguration.
      * @exception ConfigurationException if an error occurs
      */
     public static JXPathHelperConfiguration setup(Configuration config)
@@ -58,8 +59,9 @@
      * Actually add global functions and packages as well as those
      * listed in the configuration object.
      *
-     * @param context a <code>JXPathContext</code> value
-     * @param conf a <code>Configuration</code> value holding local
+     * @param setup The JXPathHelperConfiguration.
+     * @param context a <code>JXPathContext</code> value.
+     * @param conf a <code>Configuration</code> value holding local.
      * packages and functions.
      */
     private static void setup(JXPathHelperConfiguration setup, JXPathContext context, Configuration conf)
@@ -79,6 +81,47 @@
         }
     }
 
+    /**
+     * Return the String value of the attribute or element identified in the XPath expression.
+     * @param name The XPath expression
+     * @param modeConf The Configuration.
+     * @param setup The JXPathHelperConfiguration.
+     * @param contextObj The root Element to search.
+     * @return The String value of the attribute or element identified.
+     * @throws ConfigurationException if an Exception occurs.
+     */
+    public static String getAttributeValue(String name,
+                                           Configuration modeConf,
+                                           JXPathHelperConfiguration setup,
+                                           Object contextObj)
+    throws ConfigurationException {
+
+        if (contextObj == null) {
+            return null;
+        }
+
+        try {
+            JXPathContext jxContext = JXPathContext.newContext(contextObj);
+            setup(setup, jxContext, modeConf);
+            Object obj = jxContext.getValue(name);
+            if (obj != null) {
+                return obj.toString();
+            }
+            return null;
+        } catch (Exception e) {
+            throw new ConfigurationException("Module does not support <" + name + ">" + "attribute.", e);
+        }
+    }
+
+    /**
+     * Return the String value of the attribute or the Node found using the XPath expression.
+     * @param name The XPath expression
+     * @param modeConf The Configuration.
+     * @param setup The JXPathHelperConfiguration.
+     * @param contextObj The root Element to search.
+     * @return The String value of the attribute or the Element located.
+     * @throws ConfigurationException if an Exception occurs.
+     */
     public static Object getAttribute(String name,
                                       Configuration modeConf,
                                       JXPathHelperConfiguration setup,

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/BridgeElementParser.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/BridgeElementParser.java?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/BridgeElementParser.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/BridgeElementParser.java Sun Jan  6 01:35:48 2008
@@ -29,10 +29,7 @@
 import org.springframework.beans.factory.BeanDefinitionStoreException;
 import org.springframework.beans.factory.config.BeanDefinition;
 import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.BeanDefinitionBuilder;
-import org.springframework.beans.factory.support.BeanDefinitionReader;
-import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.support.*;
 import org.springframework.beans.factory.xml.ParserContext;
 import org.springframework.core.io.ResourceLoader;
 
@@ -94,10 +91,12 @@
 
     /**
      * 
-     * @param element        Can be null
-     * @param registry
-     * @param reader         Can be null
-     * @param resourceLoader
+     * @param element        Can be null.
+     * @param info           ConfigurationInfo.
+     * @param registry       BeanDefinitionRegistry.
+     * @param reader         Can be null.
+     * @param resourceLoader ResourceLoader.
+     * @throws Exception from called components.
      */
     public void createComponents(Element                element,
                                  ConfigurationInfo      info,
@@ -140,8 +139,23 @@
         beanDef.getPropertyValues().addPropertyValue("configurationInfo", new RuntimeBeanReference(ConfigurationInfo.class.getName()));
         beanDef.getPropertyValues().addPropertyValue("resourceLoader", resourceLoader);
         beanDef.getPropertyValues().addPropertyValue("location", this.getConfigurationLocation());
-
         this.register(beanDef, AvalonBeanPostProcessor.class.getName(), registry);
+
+        // add string template parser for sitemap variable substitution
+        final ChildBeanDefinition parserDef = new ChildBeanDefinition("org.apache.cocoon.template.expression.AbstractStringTemplateParser");
+        parserDef.setBeanClassName("org.apache.cocoon.components.treeprocessor.variables.LegacySitemapStringTemplateParser");
+        parserDef.setSingleton(true);
+        parserDef.setLazyInit(false);
+        parserDef.getPropertyValues().addPropertyValue("serviceManager", new RuntimeBeanReference("org.apache.avalon.framework.service.ServiceManager"));
+        this.register(parserDef, "org.apache.cocoon.el.parsing.StringTemplateParser/legacySitemap", null, registry);
+
+        final RootBeanDefinition resolverDef = new RootBeanDefinition();
+        resolverDef.setBeanClassName("org.apache.cocoon.components.treeprocessor.variables.StringTemplateParserVariableResolver");
+        resolverDef.setLazyInit(false);
+        resolverDef.setScope("prototype");
+        resolverDef.getPropertyValues().addPropertyValue("stringTemplateParser", new RuntimeBeanReference("org.apache.cocoon.el.parsing.StringTemplateParser/legacySitemap"));
+        resolverDef.getPropertyValues().addPropertyValue("objectModel", new RuntimeBeanReference("org.apache.cocoon.el.objectmodel.ObjectModel"));
+        this.register(resolverDef, "org.apache.cocoon.components.treeprocessor.variables.StringTemplateParserVariableResolver", null, registry);
     }
 
     protected ConfigurationInfo readConfiguration(String location, ResourceLoader resourceLoader)

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.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/SitemapElementParser.java?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/core/container/spring/avalon/SitemapElementParser.java Sun Jan  6 01:35:48 2008
@@ -22,10 +22,7 @@
 import org.apache.cocoon.core.container.spring.logger.LoggerUtils;
 import org.apache.cocoon.spring.configurator.WebAppContextUtils;
 import org.apache.excalibur.source.SourceResolver;
-import org.springframework.beans.factory.config.RuntimeBeanReference;
-import org.springframework.beans.factory.support.BeanDefinitionReader;
 import org.springframework.beans.factory.support.BeanDefinitionRegistry;
-import org.springframework.beans.factory.support.ChildBeanDefinition;
 import org.springframework.beans.factory.support.RootBeanDefinition;
 import org.springframework.core.io.ResourceLoader;
 import org.springframework.web.context.WebApplicationContext;
@@ -37,30 +34,6 @@
  * @version $Id$
  */
 public class SitemapElementParser extends BridgeElementParser {
-
-    /**
-     * @see org.apache.cocoon.core.container.spring.avalon.BridgeElementParser#createComponents(org.w3c.dom.Element, org.apache.cocoon.core.container.spring.avalon.ConfigurationInfo, org.springframework.beans.factory.support.BeanDefinitionRegistry, org.springframework.beans.factory.support.BeanDefinitionReader, org.springframework.core.io.ResourceLoader)
-     */
-    public void createComponents(Element element, ConfigurationInfo info,
-            BeanDefinitionRegistry registry, BeanDefinitionReader reader,
-            ResourceLoader resourceLoader) throws Exception {
-        super.createComponents(element, info, registry, reader, resourceLoader);
-        // add string template parser for sitemap variable substitution
-        final ChildBeanDefinition beanDef = new ChildBeanDefinition("org.apache.cocoon.template.expression.AbstractStringTemplateParser");
-        beanDef.setBeanClassName("org.apache.cocoon.components.treeprocessor.variables.LegacySitemapStringTemplateParser");
-        beanDef.setSingleton(true);
-        beanDef.setLazyInit(false);
-        beanDef.getPropertyValues().addPropertyValue("serviceManager", new RuntimeBeanReference("org.apache.avalon.framework.service.ServiceManager"));
-        this.register(beanDef, "org.apache.cocoon.el.parsing.StringTemplateParser/legacySitemap", null, registry);
-
-        final RootBeanDefinition resolverDef = new RootBeanDefinition();
-        resolverDef.setBeanClassName("org.apache.cocoon.components.treeprocessor.variables.StringTemplateParserVariableResolver");
-        resolverDef.setLazyInit(false);
-        resolverDef.setScope("prototype");
-        resolverDef.getPropertyValues().addPropertyValue("stringTemplateParser", new RuntimeBeanReference("org.apache.cocoon.el.parsing.StringTemplateParser/legacySitemap"));
-        resolverDef.getPropertyValues().addPropertyValue("objectModel", new RuntimeBeanReference("org.apache.cocoon.el.objectmodel.ObjectModel"));
-        this.register(resolverDef, "org.apache.cocoon.components.treeprocessor.variables.StringTemplateParserVariableResolver", null, registry);
-    }
 
     /**
      * @see BridgeElementParser#addContext(Element, BeanDefinitionRegistry)

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/environment/wrapper/AbstractRequestWrapper.java Sun Jan  6 01:35:48 2008
@@ -22,6 +22,7 @@
 import java.util.Enumeration;
 import java.util.Locale;
 import java.util.Map;
+import java.util.HashMap;
 
 import javax.servlet.RequestDispatcher;
 import javax.servlet.ServletInputStream;
@@ -31,6 +32,7 @@
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.Session;
 import org.apache.cocoon.environment.impl.AbstractRequest;
+import org.apache.commons.collections.IteratorUtils;
 
 
 /**
@@ -46,8 +48,11 @@
     /** The real {@link Request} object */
     protected final Request req;
 
+    private final Map requestAttributes = new HashMap();
+
     /**
      * Constructor
+     * @param request The Request being wrapped.
      */
     public AbstractRequestWrapper(Request request) {
         this.req = request;
@@ -74,6 +79,49 @@
         return this.req.getAttributeNames();
     }
 
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getLocalAttribute(java.lang.String)
+     */
+    public Object getLocalAttribute(String name) {
+        return this.requestAttributes.get( name );
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#getLocalAttributeNames()
+     */
+    public Enumeration getLocalAttributeNames() {
+        return IteratorUtils.asEnumeration(this.requestAttributes.keySet().iterator());
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#removeLocalAttribute(java.lang.String)
+     */
+    public void removeLocalAttribute(String name) {
+        this.requestAttributes.remove( name );
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.cocoon.environment.Request#setLocalAttribute(java.lang.String, java.lang.Object)
+     */
+    public void setLocalAttribute(String name, Object o) {
+        this.requestAttributes.put( name, o );
+    }
+
+    /**
+     * @see org.apache.cocoon.environment.Request#searchAttribute(java.lang.String)
+     */
+    public Object searchAttribute(String name) {
+        Object result = this.getLocalAttribute(name);
+        if ( result == null ) {
+            result = this.getAttribute(name);
+            if ( result == null ) {
+                result = this.req.getLocalAttribute(name);
+            }
+        }
+        return result;
+    }
+
     /* (non-Javadoc)
      * @see org.apache.cocoon.environment.Request#getCharacterEncoding()
      */
@@ -383,46 +431,11 @@
         return this.req.getAuthType();
     }       
 
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#getAttribute(java.lang.String, int)
-     */
-    public Object getAttribute(String name, int scope) {
-        return this.req.getAttribute(name, scope);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#getAttributeNames(int)
-     */
-    public Enumeration getAttributeNames(int scope) {
-        return this.req.getAttributeNames(scope);
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#removeAttribute(java.lang.String, int)
-     */
-    public void removeAttribute(String name, int scope) {
-        this.req.removeAttribute(name,scope);
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#setAttribute(java.lang.String, java.lang.Object, int)
-     */
-    public void setAttribute(String name, Object o, int scope) {
-        this.req.setAttribute(name, o, scope);
-    }
-
     /**
      * @see org.apache.cocoon.environment.Request#getSitemapURIPrefix()
      */
     public String getSitemapURIPrefix() {
         return this.req.getSitemapURIPrefix();
-    }
-
-    /**
-     * @see org.apache.cocoon.environment.Request#searchAttribute(java.lang.String)
-     */
-    public Object searchAttribute(String name) {
-        return this.req.searchAttribute(name);
     }
 
     /* (non-Javadoc)

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/environment/wrapper/RequestWrapper.java Sun Jan  6 01:35:48 2008
@@ -17,14 +17,11 @@
 package org.apache.cocoon.environment.wrapper;
 
 import java.util.Enumeration;
-import java.util.HashMap;
 import java.util.HashSet;
-import java.util.Map;
 import java.util.Set;
 
 import org.apache.cocoon.environment.Environment;
 import org.apache.cocoon.environment.Request;
-import org.apache.commons.collections.IteratorUtils;
 import org.apache.commons.collections.iterators.IteratorEnumeration;
 
 /**
@@ -51,10 +48,12 @@
     /** The request uri */
     private String requestURI;
 
-    private final Map requestAttributes = new HashMap();
-    
     /**
      * Constructor
+     * @param request The Request to be wrapped.
+     * @param requestURI The URI.
+     * @param queryString The query String.
+     * @param env The current Environment.
      */
     public RequestWrapper(Request request,
                           String  requestURI,
@@ -65,6 +64,11 @@
 
     /**
      * Constructor
+     * @param request The Request to be wrapped.
+     * @param requestURI The URI.
+     * @param queryString The query String.
+     * @param env The current Environment.
+     * @param rawMode If true only parameters from the wrapper will be returned.
      */
     public RequestWrapper(Request request,
                           String  requestURI,
@@ -173,59 +177,4 @@
         this.requestURI = buffer.toString();
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#getAttribute(java.lang.String, int)
-     */
-    public Object getAttribute(String name, int scope) {
-        if ( scope == Request.GLOBAL_SCOPE ) {
-            return super.getAttribute(name, scope);
-        }
-        return this.requestAttributes.get( name );
-    }
-        
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#getAttributeNames(int)
-     */
-    public Enumeration getAttributeNames(int scope) {
-        if ( scope == Request.GLOBAL_SCOPE ) {
-            return super.getAttributeNames(scope);
-        }
-        return IteratorUtils.asEnumeration(this.requestAttributes.keySet().iterator());
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#removeAttribute(java.lang.String, int)
-     */
-    public void removeAttribute(String name, int scope) {
-        if ( scope == Request.GLOBAL_SCOPE ) {
-            super.removeAttribute(name, scope);
-        } else {
-            this.requestAttributes.remove( name );
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.cocoon.environment.Request#setAttribute(java.lang.String, java.lang.Object, int)
-     */
-    public void setAttribute(String name, Object o, int scope) {
-        if ( scope == Request.GLOBAL_SCOPE ) {
-            super.setAttribute(name, o, scope);
-        } else {
-            this.requestAttributes.put( name, o );
-        }
-    }
-
-    /**
-     * @see org.apache.cocoon.environment.Request#searchAttribute(java.lang.String)
-     */
-    public Object searchAttribute(String name) {
-        Object result = this.getAttribute(name, REQUEST_SCOPE);
-        if ( result == null ) {
-            result = this.getAttribute(name, GLOBAL_SCOPE);
-            if ( result == null ) {
-                result = this.req.getAttribute(name, REQUEST_SCOPE);
-            }
-        }
-        return result;
-    }
 }

Modified: cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/processing/impl/MockProcessInfoProvider.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/processing/impl/MockProcessInfoProvider.java?rev=609282&r1=609281&r2=609282&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/processing/impl/MockProcessInfoProvider.java (original)
+++ cocoon/trunk/core/cocoon-sitemap/cocoon-sitemap-impl/src/main/java/org/apache/cocoon/processing/impl/MockProcessInfoProvider.java Sun Jan  6 01:35:48 2008
@@ -101,8 +101,8 @@
             return request.get(name);
         }
 
-        public Object getAttribute(String name, int scope) {
-            return request.getAttribute(name, scope);
+        public Object getLocalAttribute(String name) {
+            return request.getLocalAttribute(name);
         }
 
         public Object getAttribute(String name) {
@@ -113,8 +113,8 @@
             return request.getAttributeNames();
         }
 
-        public Enumeration getAttributeNames(int scope) {
-            return request.getAttributeNames(scope);
+        public Enumeration getLocalAttributeNames() {
+            return request.getLocalAttributeNames();
         }
 
         public Map getAttributes() {
@@ -299,8 +299,8 @@
             return request.isUserInRole(role);
         }
 
-        public void removeAttribute(String name, int scope) {
-            request.removeAttribute(name, scope);
+        public void removeLocalAttribute(String name) {
+            request.removeAttribute(name);
         }
 
         public void removeAttribute(String name) {
@@ -311,8 +311,8 @@
             return request.searchAttribute(name);
         }
 
-        public void setAttribute(String name, Object o, int scope) {
-            request.setAttribute(name, o, scope);
+        public void setLocalAttribute(String name, Object o) {
+            request.setLocalAttribute(name, o);
         }
 
         public void setAttribute(String name, Object o) {



Mime
View raw message