Author: davsclaus
Date: Sun Sep 30 07:21:46 2012
New Revision: 1391954

URL: http://svn.apache.org/viewvc?rev=1391954&view=rev
Log:
CAMEL-5456: Fixed issue when using multiple RouteBuilder with Java DSL to 
ensure onException is scoped per RouteBuilder instances, to avoid side effects 
from one builder to propagate to the next. Also this ensures the initialization 
order of the RouteBuilder does not matter. Thanks to Andreas Jacobsen for 
providing test cases.

Added:
    
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/ContextScopedOnExceptionMultipleRouteBuildersReverseTest.java
   (with props)
    
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/ContextScopedOnExceptionMultipleRouteBuildersTest.java
   (with props)
    
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/
    
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverseTest.java
   (with props)
    
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerTest.java
   (with props)
    
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/normalorder/
    
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/normalorder/BarRoute.java
   (with props)
    
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/normalorder/FooRoute.java
   (with props)
    
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/reverseorder/
    
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/reverseorder/AFooRoute.java
   (with props)
    
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/reverseorder/ZBarRoute.java
   (with props)
    
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/
    
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandler.xml
   (with props)
    
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverse.xml
   (with props)
Modified:
    
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
    
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
    
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilder.java
    
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderRef.java
    
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderSupport.java
    
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
    
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
    
camel/trunk/camel-core/src/main/java/org/apache/camel/model/OnExceptionDefinition.java
    
camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
    
camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java
    
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DummyErrorHandlerBuilder.java

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java?rev=1391954&r1=1391953&r2=1391954&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
 Sun Sep 30 07:21:46 2012
@@ -65,6 +65,13 @@ public class DeadLetterChannelBuilder ex
         return false;
     }
 
+    @Override
+    public ErrorHandlerBuilder cloneBuilder() {
+        DeadLetterChannelBuilder answer = new DeadLetterChannelBuilder();
+        super.cloneBuilder(answer);
+        return answer;
+    }
+
     // Properties
     // 
-------------------------------------------------------------------------
 

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java?rev=1391954&r1=1391953&r2=1391954&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DefaultErrorHandlerBuilder.java
 Sun Sep 30 07:21:46 2012
@@ -69,6 +69,45 @@ public class DefaultErrorHandlerBuilder 
         return false;
     }
 
+    @Override
+    public ErrorHandlerBuilder cloneBuilder() {
+        DefaultErrorHandlerBuilder answer = new DefaultErrorHandlerBuilder();
+        cloneBuilder(answer);
+        return answer;
+    }
+
+    protected void cloneBuilder(DefaultErrorHandlerBuilder other) {
+        super.cloneBuilder(other);
+
+        if (logger != null) {
+            other.setLogger(logger);
+        }
+        if (redeliveryPolicy != null) {
+            other.setRedeliveryPolicy(redeliveryPolicy.copy());
+        }
+        if (onRedelivery != null) {
+            other.setOnRedelivery(onRedelivery);
+        }
+        if (retryWhile != null) {
+            other.setRetryWhile(retryWhile);
+        }
+        if (retryWhileRef != null) {
+            other.setRetryWhileRef(retryWhileRef);
+        }
+        if (failureProcessor != null) {
+            other.setFailureProcessor(failureProcessor);
+        }
+        if (deadLetter != null) {
+            other.setDeadLetter(deadLetter);
+        }
+        if (deadLetterUri != null) {
+            other.setDeadLetterUri(deadLetterUri);
+        }
+        other.setUseOriginalMessage(useOriginalMessage);
+        other.setAsyncDelayedRedelivery(asyncDelayedRedelivery);
+        other.setExecutorServiceRef(executorServiceRef);
+    }
+
     // Builder methods
     // 
-------------------------------------------------------------------------
     public DefaultErrorHandlerBuilder backOffMultiplier(double 
backOffMultiplier) {
@@ -430,7 +469,7 @@ public class DefaultErrorHandlerBuilder 
                     throw new IllegalArgumentException("ExecutorServiceRef " + 
executorServiceRef + " not found in registry.");
                 }
             } else {
-                // no explicit configured thread pool, so leave it up to the 
error handler to deceide if it need
+                // no explicit configured thread pool, so leave it up to the 
error handler to decide if it need
                 // a default thread pool from 
CamelContext#getErrorHandlerExecutorService
                 executorService = null;
             }

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilder.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilder.java?rev=1391954&r1=1391953&r2=1391954&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilder.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilder.java
 Sun Sep 30 07:21:46 2012
@@ -34,21 +34,25 @@ public interface ErrorHandlerBuilder ext
     /**
      * Adds error handler for the given exception type
      *
-     * @param exception  the exception to handle
+     * @param routeContext  the route context
+     * @param exception     the exception to handle
      */
-    void addErrorHandlers(OnExceptionDefinition exception);
+    void addErrorHandlers(RouteContext routeContext, OnExceptionDefinition 
exception);
 
     /**
      * Adds the error handlers for the given list of exception types
      *
-     * @param exceptions  the list of exceptions to handle
+     * @param routeContext  the route context
+     * @param exceptions    the list of exceptions to handle
      */
-    void setErrorHandlers(List<OnExceptionDefinition> exceptions);
+    void setErrorHandlers(RouteContext routeContext, 
List<OnExceptionDefinition> exceptions);
 
     /**
      * Gets the error handlers
+     *
+     * @param routeContext  the route context
      */
-    List<OnExceptionDefinition> getErrorHandlers();
+    List<OnExceptionDefinition> getErrorHandlers(RouteContext routeContext);
 
     /**
      * Gets the exception policy strategy
@@ -75,4 +79,15 @@ public interface ErrorHandlerBuilder ext
      * @param handler the other error handler
      */
     void configure(RouteContext routeContext, ErrorHandler handler);
+
+    /**
+     * Clones this builder so each {@link RouteBuilder} has its private builder
+     * to use, to avoid changes from one {@link RouteBuilder} to influence the
+     * others.
+     * <p/>
+     * This is needed by the current Camel 2.x architecture.
+     *
+     * @return a clone of this {@link ErrorHandlerBuilder}
+     */
+    ErrorHandlerBuilder cloneBuilder();
 }

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=1391954&r1=1391953&r2=1391954&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 Sep 30 07:21:46 2012
@@ -16,7 +16,9 @@
  */
 package org.apache.camel.builder;
 
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.camel.ErrorHandlerFactory;
 import org.apache.camel.Processor;
@@ -33,7 +35,7 @@ import org.apache.camel.util.ObjectHelpe
 public class ErrorHandlerBuilderRef extends ErrorHandlerBuilderSupport {
     public static final String DEFAULT_ERROR_HANDLER_BUILDER = 
"CamelDefaultErrorHandlerBuilder";
     private final String ref;
-    private ErrorHandlerBuilder handler;
+    private final Map<RouteContext, ErrorHandlerBuilder> handlers = new 
HashMap<RouteContext, ErrorHandlerBuilder>();
     private boolean supportTransacted;
 
     public ErrorHandlerBuilderRef(String ref) {
@@ -41,16 +43,19 @@ public class ErrorHandlerBuilderRef exte
     }
 
     @Override
-    public void addErrorHandlers(OnExceptionDefinition exception) {
+    public void addErrorHandlers(RouteContext routeContext, 
OnExceptionDefinition exception) {
+        ErrorHandlerBuilder handler = handlers.get(routeContext);
         if (handler != null) {
-            handler.addErrorHandlers(exception);
+            handler.addErrorHandlers(routeContext, exception);
         }
-        super.addErrorHandlers(exception);
+        super.addErrorHandlers(routeContext, exception);
     }
 
     public Processor createErrorHandler(RouteContext routeContext, Processor 
processor) throws Exception {
+        ErrorHandlerBuilder handler = handlers.get(routeContext);
         if (handler == null) {
             handler = createErrorHandler(routeContext);
+            handlers.put(routeContext, handler);
         }
         return handler.createErrorHandler(routeContext, processor);
     }
@@ -59,6 +64,21 @@ public class ErrorHandlerBuilderRef exte
         return supportTransacted;
     }
 
+    @Override
+    public ErrorHandlerBuilder cloneBuilder() {
+        ErrorHandlerBuilderRef answer = new ErrorHandlerBuilderRef(ref);
+        cloneBuilder(answer);
+        return answer;
+    }
+
+    protected void cloneBuilder(ErrorHandlerBuilderRef other) {
+        super.cloneBuilder(other);
+
+        // no need to copy the handlers
+
+        other.supportTransacted = supportTransacted;
+    }
+
     /**
      * Lookup the error handler by the given ref
      *
@@ -98,7 +118,7 @@ public class ErrorHandlerBuilderRef exte
                 }
                 // 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
-                
((ErrorHandlerBuilder)answer).setErrorHandlers(other.getErrorHandlers());
+                ((ErrorHandlerBuilder)answer).setErrorHandlers(routeContext, 
other.getErrorHandlers(routeContext));
             }
         } else {
             // use specific configured error handler
@@ -142,20 +162,18 @@ public class ErrorHandlerBuilderRef exte
         return ref;
     }
 
-    public ErrorHandlerFactory getHandler() {
-        return handler;
-    }
-
     private ErrorHandlerBuilder createErrorHandler(RouteContext routeContext) {
-        handler = (ErrorHandlerBuilder)lookupErrorHandlerBuilder(routeContext, 
getRef());
+        ErrorHandlerBuilder handler = 
(ErrorHandlerBuilder)lookupErrorHandlerBuilder(routeContext, getRef());
         ObjectHelper.notNull(handler, "error handler '" + ref + "'");
 
         // configure if the handler support transacted
         supportTransacted = handler.supportTransacted();
 
-        List<OnExceptionDefinition> list = getErrorHandlers();
-        for (OnExceptionDefinition exceptionType : list) {
-            handler.addErrorHandlers(exceptionType);
+        List<OnExceptionDefinition> list = getErrorHandlers(routeContext);
+        if (list != null) {
+            for (OnExceptionDefinition exceptionType : list) {
+                handler.addErrorHandlers(routeContext, exceptionType);
+            }
         }
         return handler;
     }

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderSupport.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderSupport.java?rev=1391954&r1=1391953&r2=1391954&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderSupport.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderSupport.java
 Sun Sep 30 07:21:46 2012
@@ -17,7 +17,9 @@
 package org.apache.camel.builder;
 
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.camel.model.OnExceptionDefinition;
 import org.apache.camel.processor.ErrorHandler;
@@ -32,33 +34,48 @@ import org.apache.camel.util.ObjectHelpe
  * @version 
  */
 public abstract class ErrorHandlerBuilderSupport implements 
ErrorHandlerBuilder {
-    private List<OnExceptionDefinition> exceptions = new 
ArrayList<OnExceptionDefinition>();
+    private Map<RouteContext, List<OnExceptionDefinition>> onExceptions = new 
HashMap<RouteContext, List<OnExceptionDefinition>>();
     private ExceptionPolicyStrategy exceptionPolicyStrategy;
 
-    public void addErrorHandlers(OnExceptionDefinition exception) {
+    public void addErrorHandlers(RouteContext routeContext, 
OnExceptionDefinition exception) {
         // only add if we not already have it
-        if (!exceptions.contains(exception)) {
-            exceptions.add(exception);
+        List<OnExceptionDefinition> list = onExceptions.get(routeContext);
+        if (list == null) {
+            list = new ArrayList<OnExceptionDefinition>();
+            onExceptions.put(routeContext, list);
         }
+        if (!list.contains(exception)) {
+            list.add(exception);
+        }
+    }
+
+    protected void cloneBuilder(ErrorHandlerBuilderSupport other) {
+        if (!onExceptions.isEmpty()) {
+            Map<RouteContext, List<OnExceptionDefinition>> copy = new 
HashMap<RouteContext, List<OnExceptionDefinition>>(onExceptions);
+            other.onExceptions = copy;
+        }
+        other.exceptionPolicyStrategy = exceptionPolicyStrategy;
     }
 
     public void configure(RouteContext routeContext, ErrorHandler handler) {
         if (handler instanceof ErrorHandlerSupport) {
             ErrorHandlerSupport handlerSupport = (ErrorHandlerSupport) handler;
 
-            for (OnExceptionDefinition exception : exceptions) {
-                handlerSupport.addExceptionPolicy(routeContext, exception);
+            List<OnExceptionDefinition> list = onExceptions.get(routeContext);
+            if (list != null) {
+                for (OnExceptionDefinition exception : list) {
+                    handlerSupport.addExceptionPolicy(routeContext, exception);
+                }
             }
         }
     }
 
-    public List<OnExceptionDefinition> getErrorHandlers() {
-        return exceptions;
+    public List<OnExceptionDefinition> getErrorHandlers(RouteContext 
routeContext) {
+        return onExceptions.get(routeContext);
     }
 
-    public void setErrorHandlers(List<OnExceptionDefinition> exceptions) {
-        this.exceptions.clear();
-        this.exceptions.addAll(exceptions);
+    public void setErrorHandlers(RouteContext routeContext, 
List<OnExceptionDefinition> exceptions) {
+        this.onExceptions.put(routeContext, exceptions);
     }
 
     /**

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java?rev=1391954&r1=1391953&r2=1391954&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
 Sun Sep 30 07:21:46 2012
@@ -50,6 +50,20 @@ public class LoggingErrorHandlerBuilder 
         return false;
     }
 
+    @Override
+    public ErrorHandlerBuilder cloneBuilder() {
+        LoggingErrorHandlerBuilder answer = new LoggingErrorHandlerBuilder();
+        cloneBuilder(answer);
+        return answer;
+    }
+
+    protected void cloneBuilder(LoggingErrorHandlerBuilder other) {
+        super.cloneBuilder(other);
+
+        other.level = level;
+        other.log = log;
+    }
+
     public Processor createErrorHandler(final RouteContext routeContext, final 
Processor processor) {
         CamelLogger logger = new CamelLogger(log, level);
 

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java?rev=1391954&r1=1391953&r2=1391954&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
 Sun Sep 30 07:21:46 2012
@@ -37,4 +37,11 @@ public class NoErrorHandlerBuilder exten
     public boolean supportTransacted() {
         return false;
     }
+
+    @Override
+    public ErrorHandlerBuilder cloneBuilder() {
+        NoErrorHandlerBuilder answer = new NoErrorHandlerBuilder();
+        cloneBuilder(answer);
+        return answer;
+    }
 }

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=1391954&r1=1391953&r2=1391954&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
 Sun Sep 30 07:21:46 2012
@@ -190,7 +190,7 @@ public class OnExceptionDefinition exten
         // lookup the error handler builder
         ErrorHandlerBuilder builder = 
(ErrorHandlerBuilder)routeContext.getRoute().getErrorHandlerBuilder();
         // and add this as error handlers
-        builder.addErrorHandlers(this);
+        builder.addErrorHandlers(routeContext, this);
     }
 
     @Override

Modified: 
camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java?rev=1391954&r1=1391953&r2=1391954&view=diff
==============================================================================
--- 
camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
 (original)
+++ 
camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteDefinitionHelper.java
 Sun Sep 30 07:21:46 2012
@@ -20,6 +20,7 @@ import java.util.ArrayList;
 import java.util.List;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.builder.ErrorHandlerBuilder;
 import org.apache.camel.util.CamelContextHelper;
 import org.apache.camel.util.EndpointHelper;
 import org.apache.camel.util.ObjectHelper;
@@ -161,7 +162,13 @@ public final class RouteDefinitionHelper
 
         if (context != null) {
             // let the route inherit the error handler builder from camel 
context if none already set
-            
route.setErrorHandlerBuilderIfNull(context.getErrorHandlerBuilder());
+
+            // must clone to avoid side effects while building routes using 
multiple RouteBuilders
+            ErrorHandlerBuilder builder = context.getErrorHandlerBuilder();
+            if (builder != null) {
+                builder = builder.cloneBuilder();
+                route.setErrorHandlerBuilderIfNull(builder);
+            }
         }
 
         // init parent and error handler builder on the route

Added: 
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/ContextScopedOnExceptionMultipleRouteBuildersReverseTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/ContextScopedOnExceptionMultipleRouteBuildersReverseTest.java?rev=1391954&view=auto
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/ContextScopedOnExceptionMultipleRouteBuildersReverseTest.java
 (added)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/ContextScopedOnExceptionMultipleRouteBuildersReverseTest.java
 Sun Sep 30 07:21:46 2012
@@ -0,0 +1,53 @@
+/**
+ * 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.issues;
+
+import org.apache.camel.builder.RouteBuilder;
+
+public class ContextScopedOnExceptionMultipleRouteBuildersReverseTest extends 
ContextScopedOnExceptionMultipleRouteBuildersTest {
+
+    @Override
+    protected RouteBuilder[] createRouteBuilders() throws Exception {
+        return new RouteBuilder[]{
+            new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+                    onException(IllegalArgumentException.class)
+                            .handled(true)
+                            .to("mock:handle-bar");
+
+                    from("direct:bar")
+                            .to("mock:bar")
+                            .throwException(new 
IllegalArgumentException("Damn"));
+                }
+            },
+            new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+                    onException(Exception.class)
+                            .handled(true)
+                            .to("mock:handle-foo");
+
+                    from("direct:foo")
+                            .to("mock:foo")
+                            .throwException(new 
IllegalArgumentException("Damn"));
+                }
+            }
+        };
+    }
+
+}

Propchange: 
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/ContextScopedOnExceptionMultipleRouteBuildersReverseTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/ContextScopedOnExceptionMultipleRouteBuildersReverseTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/ContextScopedOnExceptionMultipleRouteBuildersTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/ContextScopedOnExceptionMultipleRouteBuildersTest.java?rev=1391954&view=auto
==============================================================================
--- 
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/ContextScopedOnExceptionMultipleRouteBuildersTest.java
 (added)
+++ 
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/ContextScopedOnExceptionMultipleRouteBuildersTest.java
 Sun Sep 30 07:21:46 2012
@@ -0,0 +1,85 @@
+/**
+ * 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.issues;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.DeadLetterChannelBuilder;
+import org.apache.camel.builder.RouteBuilder;
+
+public class ContextScopedOnExceptionMultipleRouteBuildersTest extends 
ContextTestSupport {
+
+    public void testFoo() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:handle-foo").expectedMessageCount(1);
+        getMockEndpoint("mock:handle-bar").expectedMessageCount(0);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+
+        template.sendBody("direct:foo", "Hello Foo");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testBar() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:handle-foo").expectedMessageCount(0);
+        getMockEndpoint("mock:handle-bar").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+
+        template.sendBody("direct:bar", "Hello Bar");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected CamelContext createCamelContext() throws Exception {
+        CamelContext context = super.createCamelContext();
+        context.setErrorHandlerBuilder(new 
DeadLetterChannelBuilder("mock:dead"));
+        return context;
+    }
+
+    @Override
+    protected RouteBuilder[] createRouteBuilders() throws Exception {
+        return new RouteBuilder[]{
+            new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+                    onException(Exception.class)
+                            .handled(true)
+                            .to("mock:handle-foo");
+
+                    from("direct:foo")
+                            .to("mock:foo")
+                            .throwException(new 
IllegalArgumentException("Damn"));
+                }
+            },
+            new RouteBuilder() {
+                @Override
+                public void configure() throws Exception {
+                    onException(IllegalArgumentException.class)
+                            .handled(true)
+                            .to("mock:handle-bar");
+
+                    from("direct:bar")
+                            .to("mock:bar")
+                            .throwException(new 
IllegalArgumentException("Damn"));
+                }
+            }
+        };
+    }
+
+}

Propchange: 
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/ContextScopedOnExceptionMultipleRouteBuildersTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/camel-core/src/test/java/org/apache/camel/issues/ContextScopedOnExceptionMultipleRouteBuildersTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: 
camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java?rev=1391954&r1=1391953&r2=1391954&view=diff
==============================================================================
--- 
camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java
 (original)
+++ 
camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/spi/SpringTransactionPolicy.java
 Sun Sep 30 07:21:46 2012
@@ -103,7 +103,7 @@ public class SpringTransactionPolicy imp
             txBuilder.setSpringTransactionPolicy(this);
             if (builder != null) {
                 // use error handlers from the configured builder
-                txBuilder.setErrorHandlers(builder.getErrorHandlers());
+                txBuilder.setErrorHandlers(routeContext, 
builder.getErrorHandlers(routeContext));
             }
             answer = createTransactionErrorHandler(routeContext, processor, 
txBuilder);
             answer.setExceptionPolicy(txBuilder.getExceptionPolicyStrategy());

Modified: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DummyErrorHandlerBuilder.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DummyErrorHandlerBuilder.java?rev=1391954&r1=1391953&r2=1391954&view=diff
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DummyErrorHandlerBuilder.java
 (original)
+++ 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/config/DummyErrorHandlerBuilder.java
 Sun Sep 30 07:21:46 2012
@@ -18,6 +18,7 @@ package org.apache.camel.spring.config;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
+import org.apache.camel.builder.ErrorHandlerBuilder;
 import org.apache.camel.builder.ErrorHandlerBuilderSupport;
 import org.apache.camel.processor.DelegateProcessor;
 import org.apache.camel.spi.RouteContext;
@@ -45,6 +46,14 @@ public class DummyErrorHandlerBuilder ex
         return false;
     }
 
+    @Override
+    public ErrorHandlerBuilder cloneBuilder() {
+        DummyErrorHandlerBuilder answer = new DummyErrorHandlerBuilder();
+        super.cloneBuilder(answer);
+        answer.beanName = beanName;
+        return answer;
+    }
+
     public Processor createErrorHandler(RouteContext routeContext, Processor 
processor) throws Exception {
         return new DelegateProcessor(processor) {
             @Override

Added: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverseTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverseTest.java?rev=1391954&view=auto
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverseTest.java
 (added)
+++ 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverseTest.java
 Sun Sep 30 07:21:46 2012
@@ -0,0 +1,51 @@
+/**
+ * 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.spring.contextscan;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class ContextScanOnExceptionAndDLCErrorHandlerReverseTest extends 
SpringTestSupport {
+
+    public void testFoo() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:handle-foo").expectedMessageCount(1);
+        getMockEndpoint("mock:handle-bar").expectedMessageCount(0);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testBar() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:handle-foo").expectedMessageCount(0);
+        getMockEndpoint("mock:handle-bar").expectedMessageCount(1);
+
+        template.sendBody("direct:bar", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new 
ClassPathXmlApplicationContext("org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverse.xml");
+    }
+}

Propchange: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverseTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverseTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerTest.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerTest.java?rev=1391954&view=auto
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerTest.java
 (added)
+++ 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerTest.java
 Sun Sep 30 07:21:46 2012
@@ -0,0 +1,51 @@
+/**
+ * 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.spring.contextscan;
+
+import org.apache.camel.spring.SpringTestSupport;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class ContextScanOnExceptionAndDLCErrorHandlerTest extends 
SpringTestSupport {
+
+    public void testFoo() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:handle-foo").expectedMessageCount(1);
+        getMockEndpoint("mock:handle-bar").expectedMessageCount(0);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testBar() throws Exception {
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:dead").expectedMessageCount(0);
+        getMockEndpoint("mock:handle-foo").expectedMessageCount(0);
+        getMockEndpoint("mock:handle-bar").expectedMessageCount(1);
+
+        template.sendBody("direct:bar", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected AbstractXmlApplicationContext createApplicationContext() {
+        return new 
ClassPathXmlApplicationContext("org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandler.xml");
+    }
+}

Propchange: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/normalorder/BarRoute.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/normalorder/BarRoute.java?rev=1391954&view=auto
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/normalorder/BarRoute.java
 (added)
+++ 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/normalorder/BarRoute.java
 Sun Sep 30 07:21:46 2012
@@ -0,0 +1,35 @@
+/**
+ * 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.spring.contextscan.normalorder;
+
+import org.apache.camel.spring.SpringRouteBuilder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class BarRoute extends SpringRouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+        onException(IllegalArgumentException.class)
+                .handled(true)
+                .to("mock:handle-bar");
+
+        from("direct:bar").routeId("bar")
+                .to("mock:bar")
+                .throwException(new IllegalArgumentException("Damn"));
+    }
+}

Propchange: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/normalorder/BarRoute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/normalorder/BarRoute.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/normalorder/FooRoute.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/normalorder/FooRoute.java?rev=1391954&view=auto
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/normalorder/FooRoute.java
 (added)
+++ 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/normalorder/FooRoute.java
 Sun Sep 30 07:21:46 2012
@@ -0,0 +1,35 @@
+/**
+ * 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.spring.contextscan.normalorder;
+
+import org.apache.camel.spring.SpringRouteBuilder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class FooRoute extends SpringRouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+        onException(Exception.class)
+                .handled(true)
+                .to("mock:handle-foo");
+
+        from("direct:foo").routeId("foo")
+                .to("mock:foo")
+                .throwException(new IllegalArgumentException("Damn"));
+    }
+}

Propchange: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/normalorder/FooRoute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/normalorder/FooRoute.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/reverseorder/AFooRoute.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/reverseorder/AFooRoute.java?rev=1391954&view=auto
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/reverseorder/AFooRoute.java
 (added)
+++ 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/reverseorder/AFooRoute.java
 Sun Sep 30 07:21:46 2012
@@ -0,0 +1,35 @@
+/**
+ * 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.spring.contextscan.reverseorder;
+
+import org.apache.camel.spring.SpringRouteBuilder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class AFooRoute extends SpringRouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+        onException(Exception.class)
+                .handled(true)
+                .to("mock:handle-foo");
+
+        from("direct:foo").routeId("foo")
+                .to("mock:foo")
+                .throwException(new IllegalArgumentException("Damn"));
+    }
+}

Propchange: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/reverseorder/AFooRoute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/reverseorder/AFooRoute.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/reverseorder/ZBarRoute.java
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/reverseorder/ZBarRoute.java?rev=1391954&view=auto
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/reverseorder/ZBarRoute.java
 (added)
+++ 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/reverseorder/ZBarRoute.java
 Sun Sep 30 07:21:46 2012
@@ -0,0 +1,35 @@
+/**
+ * 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.spring.contextscan.reverseorder;
+
+import org.apache.camel.spring.SpringRouteBuilder;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ZBarRoute extends SpringRouteBuilder {
+
+    @Override
+    public void configure() throws Exception {
+        onException(IllegalArgumentException.class)
+                .handled(true)
+                .to("mock:handle-bar");
+
+        from("direct:bar").routeId("bar")
+                .to("mock:bar")
+                .throwException(new IllegalArgumentException("Damn"));
+    }
+}

Propchange: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/reverseorder/ZBarRoute.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/contextscan/reverseorder/ZBarRoute.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandler.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandler.xml?rev=1391954&view=auto
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandler.xml
 (added)
+++ 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandler.xml
 Sun Sep 30 07:21:46 2012
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:context="http://www.springframework.org/schema/context";
+       xsi:schemaLocation="
+         http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
+         http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
+         http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context.xsd";>
+
+    <context:component-scan 
base-package="org.apache.camel.spring.contextscan.normalorder"/>
+
+    <bean id="damn" class="java.lang.IllegalArgumentException">
+        <constructor-arg index="0" value="Damn"/>
+    </bean>
+
+    <bean id="deadLetter" 
class="org.apache.camel.builder.DeadLetterChannelBuilder">
+        <property name="deadLetterUri" value="mock:dead"/>
+    </bean>
+
+    <camelContext xmlns="http://camel.apache.org/schema/spring"; 
errorHandlerRef="deadLetter">
+        <contextScan/>
+    </camelContext>
+
+</beans>

Propchange: 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandler.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandler.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandler.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverse.xml
URL: 
http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverse.xml?rev=1391954&view=auto
==============================================================================
--- 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverse.xml
 (added)
+++ 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverse.xml
 Sun Sep 30 07:21:46 2012
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<beans xmlns="http://www.springframework.org/schema/beans";
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
xmlns:context="http://www.springframework.org/schema/context";
+       xsi:schemaLocation="
+         http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans.xsd
+         http://camel.apache.org/schema/spring 
http://camel.apache.org/schema/spring/camel-spring.xsd
+         http://www.springframework.org/schema/context 
http://www.springframework.org/schema/context/spring-context.xsd";>
+
+    <context:component-scan 
base-package="org.apache.camel.spring.contextscan.reverseorder"/>
+
+    <bean id="damn" class="java.lang.IllegalArgumentException">
+        <constructor-arg index="0" value="Damn"/>
+    </bean>
+
+    <bean id="deadLetter" 
class="org.apache.camel.builder.DeadLetterChannelBuilder">
+        <property name="deadLetterUri" value="mock:dead"/>
+    </bean>
+
+    <camelContext xmlns="http://camel.apache.org/schema/spring"; 
errorHandlerRef="deadLetter">
+        <contextScan/>
+    </camelContext>
+
+</beans>

Propchange: 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverse.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverse.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: 
camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/contextscan/ContextScanOnExceptionAndDLCErrorHandlerReverse.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml


Reply via email to