Author: davsclaus
Date: Sun Oct 18 19:02:58 2009
New Revision: 826498
URL: http://svn.apache.org/viewvc?rev=826498&view=rev
Log:
CAMEL-2076: Fixed global error handler configuration in Spring XML not working
in all cases.
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java
Modified:
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java
URL:
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java?rev=826498&r1=826497&r2=826498&view=diff
==============================================================================
---
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java
(original)
+++
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java
Sun Oct 18 19:02:58 2009
@@ -18,6 +18,7 @@
import java.util.List;
+import org.apache.camel.CamelContext;
import org.apache.camel.Processor;
import org.apache.camel.model.OnExceptionDefinition;
import org.apache.camel.spi.RouteContext;
@@ -85,13 +86,18 @@
ErrorHandlerBuilderRef other = (ErrorHandlerBuilderRef) answer;
String otherRef = other.getRef();
if (!isErrorHandlerBuilderConfigured(otherRef)) {
+ // the other has also no explicit error handler configured
then fallback to the handler
+ // configured on the parent camel context
+ answer =
lookupErrorHandlerBuilder(routeContext.getCamelContext());
+ }
+ if (answer == null) {
// the other has also no explicit error handler configured
then fallback to the default error handler
// otherwise we could recursive loop forever (triggered by
createErrorHandler method)
answer = new DefaultErrorHandlerBuilder();
- // inherit the error handlers from the other as they are
to be shared
- // this is needed by camel-spring when none error handler
has been explicit configured
- answer.setErrorHandlers(other.getErrorHandlers());
}
+ // inherit the error handlers from the other as they are to be
shared
+ // this is needed by camel-spring when none error handler has
been explicit configured
+ answer.setErrorHandlers(other.getErrorHandlers());
}
} else {
// use specific configured error handler
@@ -101,6 +107,21 @@
return answer;
}
+ protected static ErrorHandlerBuilder
lookupErrorHandlerBuilder(CamelContext camelContext) {
+ ErrorHandlerBuilder answer = camelContext.getErrorHandlerBuilder();
+ if (answer instanceof ErrorHandlerBuilderRef) {
+ ErrorHandlerBuilderRef other = (ErrorHandlerBuilderRef) answer;
+ String otherRef = other.getRef();
+ if (isErrorHandlerBuilderConfigured(otherRef)) {
+ answer = camelContext.getRegistry().lookup(otherRef,
ErrorHandlerBuilder.class);
+ }
+ }
+
+ return answer;
+ }
+
+
+
/**
* Returns whether a specific error handler builder has been configured or
not.
* <p/>