You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by Claus Ibsen <ci...@silverbullet.dk> on 2008/10/22 10:47:39 UTC

RE: svn commit: r706813 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/model/ components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/

Jonathan

I think this method
+    public ExpressionType getCompletePredicate() {
+        return handledPredicate;
+    }

Should be removed it is probably from a copy class refactor.



Med venlig hilsen
 
Claus Ibsen
......................................
Silverbullet
Skovsgårdsvænget 21
8362 Hørning
Tlf. +45 2962 7576
Web: www.silverbullet.dk

-----Original Message-----
From: janstey@apache.org [mailto:janstey@apache.org] 
Sent: 22. oktober 2008 01:47
To: camel-commits@activemq.apache.org
Subject: svn commit: r706813 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/model/ components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/

Author: janstey
Date: Tue Oct 21 16:47:03 2008
New Revision: 706813

URL: http://svn.apache.org/viewvc?rev=706813&view=rev
Log:
CAMEL-1001 - Add support for all expression languages in the handled element of onException

Added:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/HandledPredicate.java   (with props)
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java
    activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/deadLetterChannelHandledExampleTest.xml

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java?rev=706813&r1=706812&r2=706813&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java Tue Oct 21 16:47:03 2008
@@ -56,7 +56,7 @@
     @XmlElement(name = "redeliveryPolicy", required = false)
     private RedeliveryPolicyType redeliveryPolicy;
     @XmlElement(name = "handled", required = false)
-    private Boolean handled;
+    private HandledPredicate handled;
     @XmlElementRef
     private List<ProcessorType<?>> outputs = new ArrayList<ProcessorType<?>>();
     @XmlTransient
@@ -111,6 +111,7 @@
     }
 
     public void addRoutes(RouteContext routeContext, Collection<Route> routes) throws Exception {
+        setHandledFromExpressionType(routeContext);
         // lets attach a processor to an error handler
         errorHandler = routeContext.createProcessor(this);
         ErrorHandlerBuilder builder = routeContext.getRoute().getErrorHandlerBuilder();
@@ -223,14 +224,23 @@
     }
 
     public Predicate getHandledPolicy() {
-        if (handled != null && handledPolicy == null) {
-            // will set the handled policy using fluent builder with the boolean value from handled that
-            // is from the spring DSL where we currently only support setting either true|false as policy
-            handled(handled);
-        }
         return handledPolicy;
     }
 
+    public void setHandled(HandledPredicate handled) {
+        this.handled = handled;
+    }
+
+    public HandledPredicate getHandled() {
+        return handled;
+    }    
+    
+    private void setHandledFromExpressionType(RouteContext routeContext) {
+        if (getHandled() != null && handledPolicy == null && routeContext != null) {  
+            handled(getHandled().createPredicate(routeContext));
+        }
+    }
+
     public void setHandledPolicy(Predicate handledPolicy) {
         this.handledPolicy = handledPolicy;
     }

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/HandledPredicate.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/HandledPredicate.java?rev=706813&view=auto
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/HandledPredicate.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/HandledPredicate.java Tue Oct 21 16:47:03 2008
@@ -0,0 +1,70 @@
+/**
+ * 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.camel.model;
+
+import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorType;
+import javax.xml.bind.annotation.XmlElementRef;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlTransient;
+
+import org.apache.camel.Predicate;
+import org.apache.camel.model.language.ExpressionType;
+import org.apache.camel.spi.RouteContext;
+
+/**
+ * Represents an XML &lt;handled/&gt; element
+ */
+@XmlRootElement(name = "handled")
+@XmlAccessorType(XmlAccessType.FIELD)
+public class HandledPredicate {
+    @XmlElementRef
+    private ExpressionType handledPredicate;
+    @XmlTransient
+    private Predicate predicate;
+
+    public HandledPredicate() {
+    }
+
+    public HandledPredicate(Predicate predicate) {
+        this.predicate = predicate;
+    }
+
+    public ExpressionType getCompletePredicate() {
+        return handledPredicate;
+    }
+
+    public void setHandledPredicate(ExpressionType handledPredicate) {
+        this.handledPredicate = handledPredicate;
+    }
+
+    public Predicate getPredicate() {
+        return predicate;
+    }
+
+    public void setPredicate(Predicate predicate) {
+        this.predicate = predicate;
+    }
+
+    public Predicate createPredicate(RouteContext routeContext) {
+        ExpressionType predicateType = getCompletePredicate();
+        if (predicateType != null && predicate == null) {
+            predicate = predicateType.createPredicate(routeContext);
+        }
+        return predicate;
+    }
+}

Propchange: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/HandledPredicate.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/deadLetterChannelHandledExampleTest.xml
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/deadLetterChannelHandledExampleTest.xml?rev=706813&r1=706812&r2=706813&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/deadLetterChannelHandledExampleTest.xml (original)
+++ activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/deadLetterChannelHandledExampleTest.xml Tue Oct 21 16:47:03 2008
@@ -43,8 +43,10 @@
                 <redeliveryPolicy>
                     <maximumRedeliveries>1</maximumRedeliveries>
                 </redeliveryPolicy>
-                <!-- mark this as handled. Spring DSL only support boolean types -->
-                <handled>true</handled>
+                <!-- mark this as handled -->
+                <handled>
+                  <constant>true</constant>
+                </handled>
                 <!-- let our order service handle this exception, call the orderFailed method -->
                 <bean ref="orderService" method="orderFailed"/>
                 <!-- and since this is a unit test we use mock for assertions -->



Re: svn commit: r706813 - in /activemq/camel/trunk: camel-core/src/main/java/org/apache/camel/model/ components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/

Posted by Jon Anstey <ja...@gmail.com>.
Good eyes Claus! I've fixed this up now.

On Wed, Oct 22, 2008 at 6:17 AM, Claus Ibsen <ci...@silverbullet.dk> wrote:

> Jonathan
>
> I think this method
> +    public ExpressionType getCompletePredicate() {
> +        return handledPredicate;
> +    }
>
> Should be removed it is probably from a copy class refactor.
>
>
>
> Med venlig hilsen
>
> Claus Ibsen
> ......................................
> Silverbullet
> Skovsgårdsvænget 21
> 8362 Hørning
> Tlf. +45 2962 7576
> Web: www.silverbullet.dk
>
> -----Original Message-----
> From: janstey@apache.org [mailto:janstey@apache.org]
> Sent: 22. oktober 2008 01:47
> To: camel-commits@activemq.apache.org
> Subject: svn commit: r706813 - in /activemq/camel/trunk:
> camel-core/src/main/java/org/apache/camel/model/
> components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/
>
> Author: janstey
> Date: Tue Oct 21 16:47:03 2008
> New Revision: 706813
>
> URL: http://svn.apache.org/viewvc?rev=706813&view=rev
> Log:
> CAMEL-1001 - Add support for all expression languages in the handled
> element of onException
>
> Added:
>
>  activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/HandledPredicate.java
>   (with props)
> Modified:
>
>  activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java
>
>  activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/deadLetterChannelHandledExampleTest.xml
>
> Modified:
> activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java
> URL:
> http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java?rev=706813&r1=706812&r2=706813&view=diff
>
> ==============================================================================
> ---
> activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java
> (original)
> +++
> activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java
> Tue Oct 21 16:47:03 2008
> @@ -56,7 +56,7 @@
>     @XmlElement(name = "redeliveryPolicy", required = false)
>     private RedeliveryPolicyType redeliveryPolicy;
>     @XmlElement(name = "handled", required = false)
> -    private Boolean handled;
> +    private HandledPredicate handled;
>     @XmlElementRef
>     private List<ProcessorType<?>> outputs = new
> ArrayList<ProcessorType<?>>();
>     @XmlTransient
> @@ -111,6 +111,7 @@
>     }
>
>     public void addRoutes(RouteContext routeContext, Collection<Route>
> routes) throws Exception {
> +        setHandledFromExpressionType(routeContext);
>         // lets attach a processor to an error handler
>         errorHandler = routeContext.createProcessor(this);
>         ErrorHandlerBuilder builder =
> routeContext.getRoute().getErrorHandlerBuilder();
> @@ -223,14 +224,23 @@
>     }
>
>     public Predicate getHandledPolicy() {
> -        if (handled != null && handledPolicy == null) {
> -            // will set the handled policy using fluent builder with the
> boolean value from handled that
> -            // is from the spring DSL where we currently only support
> setting either true|false as policy
> -            handled(handled);
> -        }
>         return handledPolicy;
>     }
>
> +    public void setHandled(HandledPredicate handled) {
> +        this.handled = handled;
> +    }
> +
> +    public HandledPredicate getHandled() {
> +        return handled;
> +    }
> +
> +    private void setHandledFromExpressionType(RouteContext routeContext) {
> +        if (getHandled() != null && handledPolicy == null && routeContext
> != null) {
> +            handled(getHandled().createPredicate(routeContext));
> +        }
> +    }
> +
>     public void setHandledPolicy(Predicate handledPolicy) {
>         this.handledPolicy = handledPolicy;
>     }
>
> Added:
> activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/HandledPredicate.java
> URL:
> http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/HandledPredicate.java?rev=706813&view=auto
>
> ==============================================================================
> ---
> activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/HandledPredicate.java
> (added)
> +++
> activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/HandledPredicate.java
> Tue Oct 21 16:47:03 2008
> @@ -0,0 +1,70 @@
> +/**
> + * 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.camel.model;
> +
> +import javax.xml.bind.annotation.XmlAccessType;
> +import javax.xml.bind.annotation.XmlAccessorType;
> +import javax.xml.bind.annotation.XmlElementRef;
> +import javax.xml.bind.annotation.XmlRootElement;
> +import javax.xml.bind.annotation.XmlTransient;
> +
> +import org.apache.camel.Predicate;
> +import org.apache.camel.model.language.ExpressionType;
> +import org.apache.camel.spi.RouteContext;
> +
> +/**
> + * Represents an XML &lt;handled/&gt; element
> + */
> +@XmlRootElement(name = "handled")
> +@XmlAccessorType(XmlAccessType.FIELD)
> +public class HandledPredicate {
> +    @XmlElementRef
> +    private ExpressionType handledPredicate;
> +    @XmlTransient
> +    private Predicate predicate;
> +
> +    public HandledPredicate() {
> +    }
> +
> +    public HandledPredicate(Predicate predicate) {
> +        this.predicate = predicate;
> +    }
> +
> +    public ExpressionType getCompletePredicate() {
> +        return handledPredicate;
> +    }
> +
> +    public void setHandledPredicate(ExpressionType handledPredicate) {
> +        this.handledPredicate = handledPredicate;
> +    }
> +
> +    public Predicate getPredicate() {
> +        return predicate;
> +    }
> +
> +    public void setPredicate(Predicate predicate) {
> +        this.predicate = predicate;
> +    }
> +
> +    public Predicate createPredicate(RouteContext routeContext) {
> +        ExpressionType predicateType = getCompletePredicate();
> +        if (predicateType != null && predicate == null) {
> +            predicate = predicateType.createPredicate(routeContext);
> +        }
> +        return predicate;
> +    }
> +}
>
> Propchange:
> activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/HandledPredicate.java
>
> ------------------------------------------------------------------------------
>    svn:eol-style = native
>
> Modified:
> activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/deadLetterChannelHandledExampleTest.xml
> URL:
> http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/deadLetterChannelHandledExampleTest.xml?rev=706813&r1=706812&r2=706813&view=diff
>
> ==============================================================================
> ---
> activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/deadLetterChannelHandledExampleTest.xml
> (original)
> +++
> activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/onexception/deadLetterChannelHandledExampleTest.xml
> Tue Oct 21 16:47:03 2008
> @@ -43,8 +43,10 @@
>                 <redeliveryPolicy>
>                     <maximumRedeliveries>1</maximumRedeliveries>
>                 </redeliveryPolicy>
> -                <!-- mark this as handled. Spring DSL only support boolean
> types -->
> -                <handled>true</handled>
> +                <!-- mark this as handled -->
> +                <handled>
> +                  <constant>true</constant>
> +                </handled>
>                 <!-- let our order service handle this exception, call the
> orderFailed method -->
>                 <bean ref="orderService" method="orderFailed"/>
>                 <!-- and since this is a unit test we use mock for
> assertions -->
>
>
>


-- 
Cheers,
Jon

http://janstey.blogspot.com/