You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2008/11/23 12:40:04 UTC
svn commit: r719979 - in /activemq/camel/trunk/camel-core/src:
main/java/org/apache/camel/model/ main/java/org/apache/camel/processor/
main/java/org/apache/camel/processor/exceptionpolicy/
test/java/org/apache/camel/processor/exceptionpolicy/
Author: davsclaus
Date: Sun Nov 23 03:40:03 2008
New Revision: 719979
URL: http://svn.apache.org/viewvc?rev=719979&view=rev
Log:
CAMEL-1104: onException now supports an optional when expression to only trigger if the expression evaluates to true
Modified:
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandlerSupport.java
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategy.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingOnlyWhenTest.java
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingWhenTest.java
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=719979&r1=719978&r2=719979&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 Sun Nov 23 03:40:03 2008
@@ -53,8 +53,8 @@
@XmlElement(name = "exception")
private List<String> exceptions = new ArrayList<String>();
- @XmlElement(name = "when", required = false)
- private WhenType when;
+ @XmlElement(name = "onWhen", required = false)
+ private WhenType onWhen;
@XmlElement(name = "redeliveryPolicy", required = false)
private RedeliveryPolicyType redeliveryPolicy;
@XmlElement(name = "handled", required = false)
@@ -82,7 +82,7 @@
@Override
public String toString() {
- return "Exception[" + getExceptionClasses() + (when != null ? " " + when : "") + " -> " + getOutputs() + "]";
+ return "Exception[" + getExceptionClasses() + (onWhen != null ? " " + onWhen : "") + " -> " + getOutputs() + "]";
}
/**
@@ -145,15 +145,15 @@
return this;
}
- public ExceptionType when(Predicate predicate) {
- setWhen(new WhenType(predicate));
+ public ExceptionType onWhen(Predicate predicate) {
+ setOnWhen(new WhenType(predicate));
return this;
}
- public ExpressionClause<ExceptionType> when() {
- when = new WhenType();
+ public ExpressionClause<ExceptionType> onWhen() {
+ onWhen = new WhenType();
ExpressionClause<ExceptionType> clause = new ExpressionClause<ExceptionType>(this);
- when.setExpression(clause);
+ onWhen.setExpression(clause);
return clause;
}
@@ -270,12 +270,12 @@
this.handledPolicy = handledPolicy;
}
- public WhenType getWhen() {
- return when;
+ public WhenType getOnWhen() {
+ return onWhen;
}
- public void setWhen(WhenType when) {
- this.when = when;
+ public void setOnWhen(WhenType onWhen) {
+ this.onWhen = onWhen;
}
// Implementation methods
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandlerSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandlerSupport.java?rev=719979&r1=719978&r2=719979&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandlerSupport.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandlerSupport.java Sun Nov 23 03:40:03 2008
@@ -44,7 +44,7 @@
List<Class> list = exceptionType.getExceptionClasses();
for (Class clazz : list) {
- ExceptionPolicyKey key = new ExceptionPolicyKey(clazz, exceptionType.getWhen());
+ ExceptionPolicyKey key = new ExceptionPolicyKey(clazz, exceptionType.getOnWhen());
exceptionPolicies.put(key, exceptionType);
}
}
Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategy.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategy.java?rev=719979&r1=719978&r2=719979&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategy.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategy.java Sun Nov 23 03:40:03 2008
@@ -133,11 +133,11 @@
* @return <tt>true</tt> if matched, <tt>false</tt> otherwise.
*/
protected boolean matchesWhen(ExceptionType type, Exchange exchange) {
- if (type.getWhen() == null || type.getWhen().getExpression() == null) {
+ if (type.getOnWhen() == null || type.getOnWhen().getExpression() == null) {
// if no predicate then it's always a match
return true;
}
- return type.getWhen().getExpression().matches(exchange);
+ return type.getOnWhen().getExpression().matches(exchange);
}
private static int getInheritanceLevel(Class clazz) {
Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingOnlyWhenTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingOnlyWhenTest.java?rev=719979&r1=719978&r2=719979&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingOnlyWhenTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingOnlyWhenTest.java Sun Nov 23 03:40:03 2008
@@ -70,7 +70,7 @@
public void configure() throws Exception {
errorHandler(deadLetterChannel(ERROR_QUEUE).maximumRedeliveries(0));
- onException(MyUserException.class).when(header("user").isNotNull())
+ onException(MyUserException.class).onWhen(header("user").isNotNull())
.maximumRedeliveries(1)
.to(ERROR_USER_QUEUE);
Modified: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingWhenTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingWhenTest.java?rev=719979&r1=719978&r2=719979&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingWhenTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/exceptionpolicy/DefaultExceptionPolicyStrategyUsingWhenTest.java Sun Nov 23 03:40:03 2008
@@ -71,7 +71,7 @@
public void configure() throws Exception {
// here we define our onException to catch MyUserException when
// there is a header[user] on the exchange that is not null
- onException(MyUserException.class).when(header("user").isNotNull())
+ onException(MyUserException.class).onWhen(header("user").isNotNull())
.maximumRedeliveries(1)
.to(ERROR_USER_QUEUE);