cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From reinh...@apache.org
Subject svn commit: r803447 - in /cocoon/cocoon3/trunk: cocoon-controller/src/main/java/org/apache/cocoon/controller/node/ cocoon-servlet/src/main/java/org/apache/cocoon/servlet/node/ cocoon-sitemap/ cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/...
Date Wed, 12 Aug 2009 11:10:59 GMT
Author: reinhard
Date: Wed Aug 12 11:10:58 2009
New Revision: 803447

URL: http://svn.apache.org/viewvc?rev=803447&view=rev
Log:
A (first) solution to the problem that nodes might be JDK proxies created by Spring AOP. There
is hopefully some better solution than unpacking proxies which ties the sitemap builder code
to Spring ... 

Added:
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/SpringProxyHelper.java
  (with props)
Modified:
    cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/node/CallNode.java
    cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/node/RedirectNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/pom.xml
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/AbstractSitemapNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ActNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ErrorNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/GenerateNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/MatchNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/OtherwiseNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ParameterNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/PipelineNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/PipelinesNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ReadNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/SelectNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/SerializeNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/Sitemap.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/SitemapNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/TransformNode.java
    cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/WhenNode.java

Modified: cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/node/CallNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/node/CallNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/node/CallNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-controller/src/main/java/org/apache/cocoon/controller/node/CallNode.java
Wed Aug 12 11:10:58 2009
@@ -34,6 +34,15 @@
     @Parameter
     private String wrapperType = "default";
 
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    public Class<?> getType() {
+        return CallNode.class;
+    }
+
     @Override
     public InvocationResult invoke(Invocation invocation) {
         Map<String, Object> parameters = new HashMap<String, Object>();

Modified: cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/node/RedirectNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/node/RedirectNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/node/RedirectNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-servlet/src/main/java/org/apache/cocoon/servlet/node/RedirectNode.java
Wed Aug 12 11:10:58 2009
@@ -29,13 +29,23 @@
     /**
      * {@inheritDoc}
      *
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    public Class<?> getType() {
+        return RedirectNode.class;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#invoke(org.apache.cocoon.sitemap.Invocation)
      */
     @Override
     public InvocationResult invoke(Invocation invocation) {
-    	if (!this.getParameters().containsKey("uri"))
-    		throw new IllegalArgumentException("redirect-to node has no @uri attribute configured.");
-    	
+    	if (!this.getParameters().containsKey("uri")) {
+            throw new IllegalArgumentException("redirect-to node has no @uri attribute configured.");
+        }
+
         // install the component
         invocation.installComponent("redirector", this.getParameters());
 

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/pom.xml?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/pom.xml (original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/pom.xml Wed Aug 12 11:10:58 2009
@@ -45,11 +45,17 @@
       <groupId>org.apache.cocoon.sax</groupId>
       <artifactId>cocoon-sax</artifactId>
     </dependency>
+    
     <dependency>
       <groupId>org.springframework</groupId>
       <artifactId>spring-context</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.springframework</groupId>
+      <artifactId>spring-aop</artifactId>
+    </dependency>    
+    
+    <dependency>
       <groupId>commons-jexl</groupId>
       <artifactId>commons-jexl</artifactId>
     </dependency>
@@ -57,6 +63,7 @@
       <groupId>jakarta-regexp</groupId>
       <artifactId>jakarta-regexp</artifactId>
     </dependency>    
+    
     <!-- Test dependencies -->
     <dependency>
       <groupId>junit</groupId>

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/AbstractSitemapNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/AbstractSitemapNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/AbstractSitemapNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/AbstractSitemapNode.java
Wed Aug 12 11:10:58 2009
@@ -30,6 +30,7 @@
 import org.apache.cocoon.sitemap.Invocation;
 import org.apache.cocoon.sitemap.node.annotations.NodeChild;
 import org.apache.cocoon.sitemap.node.annotations.Parameter;
+import org.apache.cocoon.sitemap.util.SpringProxyHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -45,22 +46,20 @@
 
     public void addChild(SitemapNode child) {
         if (child == null) {
-            String msg = "Node of class " + this.getClass().getName() + " received null child.";
-            this.logger.error(msg);
-            throw new IllegalArgumentException(msg);
+            throw new IllegalArgumentException(("Node of class " + this.getClass().getName()
+ " received null child."));
         }
 
-        if (child instanceof ParameterNode) {
+        if (child.getType().equals(ParameterNode.class)) {
             // ParameterNode are to be translated into parameters...
-            ParameterNode parameterNode = (ParameterNode) child;
+            ParameterNode parameterNode = (ParameterNode) SpringProxyHelper.unpackProxy(child);
             this.processParameter(parameterNode.getName(), parameterNode.getValue());
         } else {
             // check whether there is a special field for this child
-            Field childField = this.getChildField(child);
+            Field childField = this.getChildField(SpringProxyHelper.unpackProxy(child));
             if (childField != null) {
                 childField.setAccessible(true);
                 try {
-                    childField.set(this, child);
+                    childField.set(this, SpringProxyHelper.unpackProxy(child));
                 } catch (IllegalArgumentException e) {
                     this.logger.error("Failed to set child field for child class '" + child.getClass().getName(),
e);
                 } catch (IllegalAccessException e) {
@@ -209,5 +208,4 @@
 
         return result.toString();
     }
-
 }

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ActNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ActNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ActNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ActNode.java
Wed Aug 12 11:10:58 2009
@@ -37,6 +37,15 @@
         return InvocationResult.CONTINUE;
     }
 
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    public Class<?> getType() {
+        return ActNode.class;
+    }
+
     @Override
     public String toString() {
         return "ActNode(" + this.type + ")";

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ErrorNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ErrorNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ErrorNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ErrorNode.java
Wed Aug 12 11:10:58 2009
@@ -36,6 +36,16 @@
         return InvocationResult.NONE;
     }
 
+    /**
+     * {@inheritDoc}
+     * 
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    @Override
+    public Class<?> getType() {
+        return ErrorNode.class;
+    }
+
     @Override
     public String toString() {
         return "ErrorNode(" + this.getParent() + ")";

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/GenerateNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/GenerateNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/GenerateNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/GenerateNode.java
Wed Aug 12 11:10:58 2009
@@ -37,7 +37,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#invoke(org.apache.cocoon.sitemap.Invocation)
      */
     @Override
@@ -61,6 +61,15 @@
     /**
      * {@inheritDoc}
      * 
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    public Class<?> getType() {
+        return GenerateNode.class;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#toString()
      */
     @Override

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/MatchNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/MatchNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/MatchNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/MatchNode.java
Wed Aug 12 11:10:58 2009
@@ -71,7 +71,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#invoke(org.apache.cocoon.sitemap.Invocation)
      */
     @Override
@@ -159,6 +159,16 @@
         return matcherContextList.isEmpty() ? null : matcherContextList.getFirst();
     }
 
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    public Class<?> getType() {
+        return MatchNode.class;
+    }
+
     public void setValue(String value) {
         this.value = value;
     }

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/OtherwiseNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/OtherwiseNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/OtherwiseNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/OtherwiseNode.java
Wed Aug 12 11:10:58 2009
@@ -25,9 +25,19 @@
 @Node(name = "otherwise")
 public class OtherwiseNode extends AbstractSitemapNode {
 
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    public Class<?> getType() {
+        return OtherwiseNode.class;
+    }
+
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#invoke(org.apache.cocoon.sitemap.Invocation)
      */
     @Override
@@ -50,7 +60,7 @@
     }
 
     protected void checkParent() {
-        if (!(this.getParent() instanceof SelectNode)) {
+        if (!this.getParent().getType().equals(SelectNode.class)) {
             throw new RuntimeException("The parent node has to be a select node.");
         }
     }

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ParameterNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ParameterNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ParameterNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ParameterNode.java
Wed Aug 12 11:10:58 2009
@@ -33,6 +33,15 @@
         return this.name;
     }
 
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    public Class<?> getType() {
+        return ParameterNode.class;
+    }
+
     public String getValue() {
         return this.value;
     }

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/PipelineNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/PipelineNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/PipelineNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/PipelineNode.java
Wed Aug 12 11:10:58 2009
@@ -34,9 +34,19 @@
     @Parameter
     private String type = "caching"; // "caching" is the default type
 
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    public Class<?> getType() {
+        return PipelineNode.class;
+    }
+
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#invoke(org.apache.cocoon.sitemap.Invocation)
      */
     @Override
@@ -68,7 +78,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#toString()
      */
     @Override

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/PipelinesNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/PipelinesNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/PipelinesNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/PipelinesNode.java
Wed Aug 12 11:10:58 2009
@@ -29,9 +29,19 @@
     @NodeChild
     private ErrorNode errorNode;
 
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    public Class<?> getType() {
+        return PipelinesNode.class;
+    }
+
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#invoke(org.apache.cocoon.sitemap.Invocation)
      */
     @Override

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ReadNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ReadNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ReadNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/ReadNode.java
Wed Aug 12 11:10:58 2009
@@ -37,7 +37,16 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    public Class<?> getType() {
+        return ReadNode.class;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#invoke(org.apache.cocoon.sitemap.Invocation)
      */
     @Override
@@ -60,7 +69,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#toString()
      */
     @Override

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/SelectNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/SelectNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/SelectNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/SelectNode.java
Wed Aug 12 11:10:58 2009
@@ -27,9 +27,19 @@
     @Parameter
     private String value;
 
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    public Class<?> getType() {
+        return SelectNode.class;
+    }
+
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#invoke(org.apache.cocoon.sitemap.Invocation)
      */
     @Override

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/SerializeNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/SerializeNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/SerializeNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/SerializeNode.java
Wed Aug 12 11:10:58 2009
@@ -29,13 +29,18 @@
     @Parameter
     private String type = "xml"; // default is "xml";
 
-    public String getType() {
-        return this.type;
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    public Class<?> getType() {
+        return SerializeNode.class;
     }
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#invoke(org.apache.cocoon.sitemap.Invocation)
      */
     @Override
@@ -49,7 +54,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#toString()
      */
     @Override

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/Sitemap.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/Sitemap.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/Sitemap.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/Sitemap.java
Wed Aug 12 11:10:58 2009
@@ -25,7 +25,16 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    public Class<?> getType() {
+        return Sitemap.class;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#invoke(org.apache.cocoon.sitemap.Invocation)
      */
     @Override

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/SitemapNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/SitemapNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/SitemapNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/SitemapNode.java
Wed Aug 12 11:10:58 2009
@@ -33,4 +33,6 @@
     void setParameters(Map<String, String> parameters);
 
     InvocationResult invoke(Invocation invocation);
+
+    Class<?> getType();
 }

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/TransformNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/TransformNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/TransformNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/TransformNode.java
Wed Aug 12 11:10:58 2009
@@ -37,7 +37,16 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    public Class<?> getType() {
+        return TransformNode.class;
+    }
+
+    /**
+     * {@inheritDoc}
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#invoke(org.apache.cocoon.sitemap.Invocation)
      */
     @Override
@@ -60,7 +69,7 @@
 
     /**
      * {@inheritDoc}
-     * 
+     *
      * @see org.apache.cocoon.sitemap.node.AbstractSitemapNode#toString()
      */
     @Override

Modified: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/WhenNode.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/WhenNode.java?rev=803447&r1=803446&r2=803447&view=diff
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/WhenNode.java
(original)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/node/WhenNode.java
Wed Aug 12 11:10:58 2009
@@ -19,10 +19,22 @@
 package org.apache.cocoon.sitemap.node;
 
 import org.apache.cocoon.sitemap.Invocation;
+import org.apache.cocoon.sitemap.util.SpringProxyHelper;
 
 @Node(name = "when")
 public class WhenNode extends MatchNode {
 
+
+    /**
+     * {@inheritDoc}
+     *
+     * @see org.apache.cocoon.sitemap.node.SitemapNode#getType()
+     */
+    @Override
+    public Class<?> getType() {
+        return WhenNode.class;
+    }
+
     @Override
     public InvocationResult invoke(Invocation invocation) {
         this.checkParent();
@@ -48,8 +60,8 @@
      * Check if the parent is a select node.
      */
     protected void checkParent() {
-        if (this.getParent() instanceof SelectNode) {
-            SelectNode parentMatchNode = (SelectNode) this.getParent();
+        if (this.getParent().getType().equals(SelectNode.class)) {
+            SelectNode parentMatchNode = (SelectNode) SpringProxyHelper.unpackProxy(this.getParent());
             this.setValue(parentMatchNode.getValue());
         } else {
             throw new RuntimeException("The parent node has to be a select node.");

Added: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/SpringProxyHelper.java
URL: http://svn.apache.org/viewvc/cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/SpringProxyHelper.java?rev=803447&view=auto
==============================================================================
--- cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/SpringProxyHelper.java
(added)
+++ cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/SpringProxyHelper.java
Wed Aug 12 11:10:58 2009
@@ -0,0 +1,49 @@
+/*
+ * 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.
+ */
+package org.apache.cocoon.sitemap.util;
+
+import org.springframework.aop.framework.Advised;
+
+public class SpringProxyHelper {
+
+    private SpringProxyHelper() {
+        // only static usage
+    }
+
+    @SuppressWarnings("unchecked")
+    public static <T> T unpackProxy(T proxy) {
+        if (proxy instanceof Advised) {
+            Advised advised = (Advised) proxy;
+            try {
+                return (T) advised.getTargetSource().getTarget();
+            } catch (Exception e) {
+                throw new ProxyUnpackException(e);
+            }
+        }
+
+        return proxy;
+    }
+
+    public static class ProxyUnpackException extends RuntimeException {
+
+        private static final long serialVersionUID = 1L;
+
+        public ProxyUnpackException(Throwable t) {
+            super(t);
+        }
+    }
+}

Propchange: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/SpringProxyHelper.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/SpringProxyHelper.java
------------------------------------------------------------------------------
    svn:keywords = Id

Propchange: cocoon/cocoon3/trunk/cocoon-sitemap/src/main/java/org/apache/cocoon/sitemap/util/SpringProxyHelper.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain



Mime
View raw message