camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r959640 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/test/java/org/apache/camel/issues/ camel-core/src/test/java/org/apache/camel/processor/onexcepti...
Date Thu, 01 Jul 2010 12:47:49 GMT
Author: davsclaus
Date: Thu Jul  1 12:47:49 2010
New Revision: 959640

URL: http://svn.apache.org/viewvc?rev=959640&view=rev
Log:
CAMEL-2889: Renamed retryUntil to retryWhile as its a more meaningful name what it does.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryPolicy.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryContextScopedUntilRecipientListIssueTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryContextScopedUntilRecipientListParallelIssueTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListIssueTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListParallelIssueTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRetryUntilTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRetryUntilWithDefaultErrorHandlerTest.java
    camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
    camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SOnExceptionDefinition.scala
    camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/OnExceptionTest.scala

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java?rev=959640&r1=959639&r2=959640&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
Thu Jul  1 12:47:49 2010
@@ -59,8 +59,8 @@ public class OnExceptionDefinition exten
     private List<String> exceptions = new ArrayList<String>();
     @XmlElement(name = "onWhen", required = false)
     private WhenDefinition onWhen;
-    @XmlElement(name = "retryUntil", required = false)
-    private ExpressionSubElementDefinition retryUntil;
+    @XmlElement(name = "retryWhile", required = false)
+    private ExpressionSubElementDefinition retryWhile;
     @XmlElement(name = "redeliveryPolicy", required = false)
     private RedeliveryPolicyDefinition redeliveryPolicy;
     @XmlElement(name = "handled", required = false)
@@ -82,7 +82,7 @@ public class OnExceptionDefinition exten
     @XmlTransient
     private Predicate continuedPolicy;
     @XmlTransient
-    private Predicate retryUntilPolicy;
+    private Predicate retryWhilePolicy;
     @XmlTransient
     private Processor onRedelivery;
 
@@ -136,7 +136,7 @@ public class OnExceptionDefinition exten
     public void addRoutes(RouteContext routeContext, Collection<Route> routes) throws
Exception {
         setHandledFromExpressionType(routeContext);
         setContinuedFromExpressionType(routeContext);
-        setRetryUntilFromExpressionType(routeContext);
+        setRetryWhileFromExpressionType(routeContext);
 
         // only one of handled or continued is allowed
         if (getHandledPolicy() != null && getContinuedPolicy() != null) {
@@ -285,24 +285,28 @@ public class OnExceptionDefinition exten
     }
 
     /**
-     * Sets the retry until predicate.
+     * Sets the retry while predicate.
+     * <p/>
+     * Will continue retrying until predicate returns <tt>false</tt>.
      *
-     * @param until predicate that determines when to stop retrying
+     * @param retryWhile predicate that determines when to stop retrying
      * @return the builder
      */
-    public OnExceptionDefinition retryUntil(Predicate until) {
-        setRetryUntilPolicy(until);
+    public OnExceptionDefinition retryWhile(Predicate retryWhile) {
+        setRetryWhilePolicy(retryWhile);
         return this;
     }
 
     /**
-     * Sets the retry until expression.
+     * Sets the retry while expression.
+     * <p/>
+     * Will continue retrying until expression evaluates to <tt>false</tt>.
      *
-     * @param until expression that determines when to stop retrying
+     * @param retryWhile expression that determines when to stop retrying
      * @return the builder
      */
-    public OnExceptionDefinition retryUntil(Expression until) {
-        setRetryUntilPolicy(toPredicate(until));
+    public OnExceptionDefinition retryWhile(Expression retryWhile) {
+        setRetryWhilePolicy(toPredicate(retryWhile));
         return this;
     }
 
@@ -636,20 +640,20 @@ public class OnExceptionDefinition exten
         this.onWhen = onWhen;
     }
 
-    public ExpressionSubElementDefinition getRetryUntil() {
-        return retryUntil;
+    public ExpressionSubElementDefinition getRetryWhile() {
+        return retryWhile;
     }
 
-    public void setRetryUntil(ExpressionSubElementDefinition retryUntil) {
-        this.retryUntil = retryUntil;
+    public void setRetryWhile(ExpressionSubElementDefinition retryWhile) {
+        this.retryWhile = retryWhile;
     }
 
-    public Predicate getRetryUntilPolicy() {
-        return retryUntilPolicy;
+    public Predicate getRetryWhilePolicy() {
+        return retryWhilePolicy;
     }
 
-    public void setRetryUntilPolicy(Predicate retryUntilPolicy) {
-        this.retryUntilPolicy = retryUntilPolicy;
+    public void setRetryWhilePolicy(Predicate retryWhilePolicy) {
+        this.retryWhilePolicy = retryWhilePolicy;
     }
 
     public Processor getOnRedelivery() {
@@ -708,9 +712,9 @@ public class OnExceptionDefinition exten
         }
     }
 
-    private void setRetryUntilFromExpressionType(RouteContext routeContext) {
-        if (getRetryUntil() != null && retryUntilPolicy == null && routeContext
!= null) {
-            retryUntil(getRetryUntil().createPredicate(routeContext));
+    private void setRetryWhileFromExpressionType(RouteContext routeContext) {
+        if (getRetryWhile() != null && retryWhilePolicy == null && routeContext
!= null) {
+            retryWhile(getRetryWhile().createPredicate(routeContext));
         }
     }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java?rev=959640&r1=959639&r2=959640&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryErrorHandler.java
Thu Jul  1 12:47:49 2010
@@ -67,7 +67,7 @@ public abstract class RedeliveryErrorHan
         boolean sync = true;
         int redeliveryCounter;
         long redeliveryDelay;
-        Predicate retryUntilPredicate;
+        Predicate retryWhilePredicate;
 
         // default behavior which can be overloaded on a per exception basis
         RedeliveryPolicy currentRedeliveryPolicy = redeliveryPolicy;
@@ -416,7 +416,7 @@ public abstract class RedeliveryErrorHan
             data.currentRedeliveryPolicy = exceptionPolicy.createRedeliveryPolicy(exchange.getContext(),
data.currentRedeliveryPolicy);
             data.handledPredicate = exceptionPolicy.getHandledPolicy();
             data.continuedPredicate = exceptionPolicy.getContinuedPolicy();
-            data.retryUntilPredicate = exceptionPolicy.getRetryUntilPolicy();
+            data.retryWhilePredicate = exceptionPolicy.getRetryWhilePolicy();
             data.useOriginalInMessage = exceptionPolicy.getUseOriginalMessagePolicy();
 
             // route specific failure handler?
@@ -670,7 +670,7 @@ public abstract class RedeliveryErrorHan
             }
             return false;
         }
-        return data.currentRedeliveryPolicy.shouldRedeliver(exchange, data.redeliveryCounter,
data.retryUntilPredicate);
+        return data.currentRedeliveryPolicy.shouldRedeliver(exchange, data.redeliveryCounter,
data.retryWhilePredicate);
     }
 
     /**

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryPolicy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryPolicy.java?rev=959640&r1=959639&r2=959640&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryPolicy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/RedeliveryPolicy.java
Thu Jul  1 12:47:49 2010
@@ -132,13 +132,13 @@ public class RedeliveryPolicy implements
      *
      * @param exchange  the current exchange
      * @param redeliveryCounter  the current retry counter
-     * @param retryUntil  an optional predicate to determine if we should redeliver or not
+     * @param retryWhile  an optional predicate to determine if we should redeliver or not
      * @return true to redeliver, false to stop
      */
-    public boolean shouldRedeliver(Exchange exchange, int redeliveryCounter, Predicate retryUntil)
{
+    public boolean shouldRedeliver(Exchange exchange, int redeliveryCounter, Predicate retryWhile)
{
         // predicate is always used if provided
-        if (retryUntil != null) {
-            return retryUntil.matches(exchange);
+        if (retryWhile != null) {
+            return retryWhile.matches(exchange);
         }
 
         if (getMaximumRedeliveries() < 0) {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryContextScopedUntilRecipientListIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryContextScopedUntilRecipientListIssueTest.java?rev=959640&r1=959639&r2=959640&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryContextScopedUntilRecipientListIssueTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryContextScopedUntilRecipientListIssueTest.java
Thu Jul  1 12:47:49 2010
@@ -28,7 +28,7 @@ public class RetryContextScopedUntilReci
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                onException(Exception.class).retryUntil(bean("myRetryBean")).end();
+                onException(Exception.class).retryWhile(bean("myRetryBean")).end();
                 
                 from("seda:start")
                     .recipientList(header("recipientListHeader"))

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryContextScopedUntilRecipientListParallelIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryContextScopedUntilRecipientListParallelIssueTest.java?rev=959640&r1=959639&r2=959640&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryContextScopedUntilRecipientListParallelIssueTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryContextScopedUntilRecipientListParallelIssueTest.java
Thu Jul  1 12:47:49 2010
@@ -28,7 +28,7 @@ public class RetryContextScopedUntilReci
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                onException(Exception.class).retryUntil(bean("myRetryBean")).end();
+                onException(Exception.class).retryWhile(bean("myRetryBean")).end();
 
                 from("seda:start")
                     .recipientList(header("recipientListHeader")).parallelProcessing()

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListIssueTest.java?rev=959640&r1=959639&r2=959640&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListIssueTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListIssueTest.java
Thu Jul  1 12:47:49 2010
@@ -258,7 +258,7 @@ public class RetryRouteScopedUntilRecipi
             @Override
             public void configure() throws Exception {
                 from("seda:start")
-                    .onException(Exception.class).retryUntil(bean("myRetryBean")).end()
+                    .onException(Exception.class).retryWhile(bean("myRetryBean")).end()
                     .recipientList(header("recipientListHeader"))
                     .to("mock:result");
 
@@ -270,7 +270,7 @@ public class RetryRouteScopedUntilRecipi
     public class MyRetryBean {
 
         // using bean binding we can bind the information from the exchange to the types
we have in our method signature
-        public boolean retryUntil(@Header(Exchange.REDELIVERY_COUNTER) Integer counter, @Body
String body, @ExchangeException Exception causedBy) {
+        public boolean retry(@Header(Exchange.REDELIVERY_COUNTER) Integer counter, @Body
String body, @ExchangeException Exception causedBy) {
             // NOTE: counter is the redelivery attempt, will start from 1
             invoked.incrementAndGet();
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListParallelIssueTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListParallelIssueTest.java?rev=959640&r1=959639&r2=959640&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListParallelIssueTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/issues/RetryRouteScopedUntilRecipientListParallelIssueTest.java
Thu Jul  1 12:47:49 2010
@@ -30,7 +30,7 @@ public class RetryRouteScopedUntilRecipi
             public void configure() throws Exception {
 
                 from("seda:start")
-                    .onException(Exception.class).retryUntil(bean("myRetryBean")).end()
+                    .onException(Exception.class).retryWhile(bean("myRetryBean")).end()
                     .recipientList(header("recipientListHeader")).parallelProcessing()
                     .to("mock:result");
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRetryUntilTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRetryUntilTest.java?rev=959640&r1=959639&r2=959640&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRetryUntilTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRetryUntilTest.java
Thu Jul  1 12:47:49 2010
@@ -50,9 +50,9 @@ public class OnExceptionRetryUntilTest e
                 // we want to use a predicate for retries so we can determine in our bean
                 // when retry should stop, notice it will overrule the global error handler
                 // where we defined at most 1 redelivery attempt. Here we will continue until
-                // the predicate false
+                // the predicate returns false
                 onException(MyFunctionalException.class)
-                        .retryUntil(bean("myRetryHandler"))
+                        .retryWhile(bean("myRetryHandler"))
                         .handled(true)
                         .transform().constant("Sorry");
                 // END SNIPPET: e1
@@ -74,7 +74,7 @@ public class OnExceptionRetryUntilTest e
     public class MyRetryBean {
 
         // using bean binding we can bind the information from the exchange to the types
we have in our method signature
-        public boolean retryUntil(@Header(Exchange.REDELIVERY_COUNTER) Integer counter, @Body
String body, @ExchangeException Exception causedBy) {
+        public boolean retry(@Header(Exchange.REDELIVERY_COUNTER) Integer counter, @Body
String body, @ExchangeException Exception causedBy) {
             // NOTE: counter is the redelivery attempt, will start from 1
             invoked++;
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRetryUntilWithDefaultErrorHandlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRetryUntilWithDefaultErrorHandlerTest.java?rev=959640&r1=959639&r2=959640&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRetryUntilWithDefaultErrorHandlerTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/onexception/OnExceptionRetryUntilWithDefaultErrorHandlerTest.java
Thu Jul  1 12:47:49 2010
@@ -47,7 +47,7 @@ public class OnExceptionRetryUntilWithDe
                 errorHandler(defaultErrorHandler().maximumRedeliveries(1).logStackTrace(false));
 
                 onException(MyFunctionalException.class)
-                        .retryUntil(bean("myRetryHandler"))
+                        .retryWhile(bean("myRetryHandler"))
                         .handled(true)
                         .transform().constant("Sorry").stop();
 
@@ -67,7 +67,7 @@ public class OnExceptionRetryUntilWithDe
     public class MyRetryBean {
 
         // using bean binding we can bind the information from the exchange to the types
we have in our method signature
-        public boolean retryUntil(@Header(Exchange.REDELIVERY_COUNTER) Integer counter, @Body
String body, @ExchangeException Exception causedBy) {
+        public boolean retry(@Header(Exchange.REDELIVERY_COUNTER) Integer counter, @Body
String body, @ExchangeException Exception causedBy) {
             // NOTE: counter is the redelivery attempt, will start from 1
             invoked++;
 

Modified: camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java?rev=959640&r1=959639&r2=959640&view=diff
==============================================================================
--- camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
(original)
+++ camel/trunk/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
Thu Jul  1 12:47:49 2010
@@ -295,7 +295,7 @@ public class CamelNamespaceHandler imple
                     findLanguage(((CatchDefinition) def).getHandled(), languages);
                 }
                 if (def instanceof OnExceptionDefinition) {
-                    findLanguage(((OnExceptionDefinition) def).getRetryUntil(), languages);
+                    findLanguage(((OnExceptionDefinition) def).getRetryWhile(), languages);
                     findLanguage(((OnExceptionDefinition) def).getHandled(), languages);
                     findLanguage(((OnExceptionDefinition) def).getContinued(), languages);
                 }

Modified: camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SOnExceptionDefinition.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SOnExceptionDefinition.scala?rev=959640&r1=959639&r2=959640&view=diff
==============================================================================
--- camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SOnExceptionDefinition.scala
(original)
+++ camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SOnExceptionDefinition.scala
Thu Jul  1 12:47:49 2010
@@ -31,15 +31,18 @@ case class SOnExceptionDefinition(overri
   def handled = wrap(target.handled(true))
   def handled(predicate: Exchange => Any) = wrap(target.handled(predicateBuilder(predicate)))
 
+  def continued = wrap(target.continued(true))
+  def continued(predicate: Exchange => Any) = wrap(target.continued(predicateBuilder(predicate)))
+
   def maximumRedeliveries(count: Int) = wrap(target.maximumRedeliveries(count))
 
   def onRedelivery(processor: Exchange => Unit) = wrap(target.onRedelivery(new ScalaProcessor(processor)))
 
   def onWhen(when: Exchange => Any) = wrap(target.onWhen(predicateBuilder(when)))
 
-  def retryUntil(until: Exchange => Any) = wrap(target.retryUntil(predicateBuilder(until)))
+  def retryWhile(retryWhile: Exchange => Any) = wrap(target.retryWhile(predicateBuilder(retryWhile)))
 
-  def useOriginalMessage = wrap(target.useOriginalBody)
+  def useOriginalMessage = wrap(target.useOriginalMessage)
 
   override def wrap(block: => Unit) = super.wrap(block).asInstanceOf[SOnExceptionDefinition]
   

Modified: camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/OnExceptionTest.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/OnExceptionTest.scala?rev=959640&r1=959639&r2=959640&view=diff
==============================================================================
--- camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/OnExceptionTest.scala
(original)
+++ camel/trunk/components/camel-scala/src/test/scala/org/apache/camel/scala/dsl/OnExceptionTest.scala
Thu Jul  1 12:47:49 2010
@@ -95,7 +95,7 @@ class SOnExceptionRetryUntilWithDefaultE
 
     handle[MyFunctionalException] {
       transform("Sorry")
-    }.retryUntil(threeTimes).handled
+    }.retryWhile(threeTimes).handled
 
     "direct:start" throwException(new MyFunctionalException("Sorry, you cannot do this"))
   }



Mime
View raw message