svn commit: r564295 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/builder/ main/java/org/apache/camel/model/ main/java/org/apache/camel/processor/ main/resources/org/apache/camel/model/ test/java/org/apache/camel/processor/

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r564295 - in /activemq/camel/trunk/camel-core/src: main/java/org/apache/camel/builder/ main/java/org/apache/camel/model/ main/java/org/apache/camel/processor/ main/resources/org/apache/camel/model/ test/java/org/apache/camel/processor/

jstrachan-2
Author: jstrachan
Date: Thu Aug  9 10:43:51 2007
New Revision: 564295

URL: http://svn.apache.org/viewvc?view=rev&rev=564295
Log:
added the exception(Class) expression to the DSL for easier DSL based exception routing, for CAMEL-93

Added:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderSupport.java   (with props)
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java   (contents, props changed)
      - copied, changed from r564272, activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/CatchType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandlerSupport.java   (with props)
    activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithExceptionTest.java   (contents, props changed)
      - copied, changed from r564133, activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationTest.java
Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TryType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java
    activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java?view=diff&rev=564295&r1=564294&r2=564295
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/DeadLetterChannelBuilder.java Thu Aug  9 10:43:51 2007
@@ -33,7 +33,7 @@
  *
  * @version $Revision$
  */
-public class DeadLetterChannelBuilder implements ErrorHandlerBuilder {
+public class DeadLetterChannelBuilder extends ErrorHandlerBuilderSupport {
     private RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
     private ProcessorFactory deadLetterFactory;
     private Processor defaultDeadLetterEndpoint;
@@ -60,7 +60,9 @@
 
     public Processor createErrorHandler(Processor processor) throws Exception {
         Processor deadLetter = getDeadLetterFactory().createProcessor();
-        return new DeadLetterChannel(processor, deadLetter, getRedeliveryPolicy(), getLogger());
+        DeadLetterChannel answer = new DeadLetterChannel(processor, deadLetter, getRedeliveryPolicy(), getLogger());
+        configure(answer);
+        return answer;
     }
 
     // Builder methods

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilder.java?view=diff&rev=564295&r1=564294&r2=564295
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilder.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilder.java Thu Aug  9 10:43:51 2007
@@ -19,17 +19,21 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 
+import java.util.List;
+
 /**
  * @version $Revision$
  */
-public interface ErrorHandlerBuilder<E extends Exchange> {
+public interface ErrorHandlerBuilder {
     /**
      * Creates a copy of this builder
      */
-    ErrorHandlerBuilder<E> copy();
+    ErrorHandlerBuilder copy();
 
     /**
      * Creates the error handler interceptor
      */
     Processor createErrorHandler(Processor processor) throws Exception;
+
+    void addErrorHandlers(List<Class> exceptionClasses, Processor errorHandler);
 }

Added: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderSupport.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderSupport.java?view=auto&rev=564295
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderSupport.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ErrorHandlerBuilderSupport.java Thu Aug  9 10:43:51 2007
@@ -0,0 +1,50 @@
+/**
+ *
+ * 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.builder;
+
+import org.apache.camel.Processor;
+import org.apache.camel.processor.ErrorHandlerSupport;
+
+import java.util.IdentityHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public abstract class ErrorHandlerBuilderSupport implements ErrorHandlerBuilder {
+    private Map<List<Class>, Processor> exceptionHandlers = new IdentityHashMap<List<Class>, Processor>();
+
+    public void addErrorHandlers(List<Class> exceptionClasses, Processor errorHandler) {
+        exceptionHandlers.put(exceptionClasses, errorHandler);
+    }
+
+    protected void configure(ErrorHandlerSupport handler) {
+        Set<Map.Entry<List<Class>, Processor>> entries = exceptionHandlers.entrySet();
+        for (Map.Entry<List<Class>, Processor> entry : entries) {
+            configure(handler, entry.getKey(), entry.getValue());
+        }
+    }
+
+    protected void configure(ErrorHandlerSupport handler, List<Class> exceptionTypes, Processor exceptionProcessor) {
+        for (Class exceptionType : exceptionTypes) {
+            handler.addCustomProcessor(exceptionType, exceptionProcessor);
+        }
+    }
+}

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

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java?view=diff&rev=564295&r1=564294&r2=564295
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/LoggingErrorHandlerBuilder.java Thu Aug  9 10:43:51 2007
@@ -20,6 +20,7 @@
 import org.apache.camel.processor.Logger;
 import org.apache.camel.processor.LoggingErrorHandler;
 import org.apache.camel.processor.LoggingLevel;
+import org.apache.camel.processor.ErrorHandlerSupport;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -28,7 +29,7 @@
  *
  * @version $Revision$
  */
-public class LoggingErrorHandlerBuilder implements ErrorHandlerBuilder {
+public class LoggingErrorHandlerBuilder extends ErrorHandlerBuilderSupport {
     private Log log = LogFactory.getLog(Logger.class);
     private LoggingLevel level = LoggingLevel.INFO;
 
@@ -52,7 +53,9 @@
     }
 
     public Processor createErrorHandler(Processor processor) {
-        return new LoggingErrorHandler(processor, log, level);
+        LoggingErrorHandler handler = new LoggingErrorHandler(processor, log, level);
+        configure(handler);
+        return handler;
     }
 
     public LoggingLevel getLevel() {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java?view=diff&rev=564295&r1=564294&r2=564295
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/NoErrorHandlerBuilder.java Thu Aug  9 10:43:51 2007
@@ -28,8 +28,8 @@
  *
  * @version $Revision$
  */
-public class NoErrorHandlerBuilder<E extends Exchange> implements ErrorHandlerBuilder<E> {
-    public ErrorHandlerBuilder<E> copy() {
+public class NoErrorHandlerBuilder extends ErrorHandlerBuilderSupport {
+    public ErrorHandlerBuilder copy() {
         return this;
     }
 

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java?view=diff&rev=564295&r1=564294&r2=564295
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/RouteBuilder.java Thu Aug  9 10:43:51 2007
@@ -26,6 +26,7 @@
 import org.apache.camel.model.ProcessorType;
 import org.apache.camel.model.RouteType;
 import org.apache.camel.model.RoutesType;
+import org.apache.camel.model.ExceptionType;
 import org.apache.camel.processor.DelegateProcessor;
 
 import java.util.ArrayList;
@@ -121,6 +122,13 @@
      */
     public OtherwiseType intercept(Predicate predicate) {
         return routeCollection.intercept(predicate);
+    }
+
+    /**
+     * Adds an exception handler route for the given exception type
+     */
+    public ExceptionType exception(Class exceptionType) {
+        return routeCollection.exception(exceptionType);
     }
 
     // Properties

Copied: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java (from r564272, activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/CatchType.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java?view=diff&rev=564295&p1=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/CatchType.java&r1=564272&p2=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java&r2=564295
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/CatchType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ExceptionType.java Thu Aug  9 10:43:51 2007
@@ -18,7 +18,7 @@
 
 import java.util.ArrayList;
 import java.util.List;
-
+import java.util.Collection;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlElement;
@@ -27,6 +27,8 @@
 import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.camel.Processor;
+import org.apache.camel.Route;
+import org.apache.camel.builder.ErrorHandlerBuilder;
 import org.apache.camel.impl.RouteContext;
 import org.apache.camel.processor.CatchProcessor;
 import org.apache.camel.util.ObjectHelper;
@@ -34,9 +36,9 @@
 /**
  * @version $Revision: 1.1 $
  */
-@XmlRootElement(name = "catch")
+@XmlRootElement(name = "error")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class CatchType extends ProcessorType {
+public class ExceptionType extends ProcessorType {
     @XmlElementRef
     private List<InterceptorType> interceptors = new ArrayList<InterceptorType>();
     @XmlElement(name = "exception")
@@ -46,21 +48,28 @@
     @XmlTransient
     private List<Class> exceptionClasses;
 
-    public CatchType() {
+    public ExceptionType() {
     }
 
-    public CatchType(List<Class> exceptionClasses) {
+    public ExceptionType(List<Class> exceptionClasses) {
         this.exceptionClasses = exceptionClasses;
     }
 
-    public CatchType(Class exceptionType) {
+    public ExceptionType(Class exceptionType) {
         exceptionClasses = new ArrayList<Class>();
         exceptionClasses.add(exceptionType);
     }
 
     @Override
     public String toString() {
-        return "Catch[ " + getExceptionClasses() + " -> " + getOutputs() + "]";
+        return "Error[ " + getExceptionClasses() + " -> " + getOutputs() + "]";
+    }
+
+    public void addRoutes(RouteContext routeContext, Collection<Route> routes) throws Exception {
+        // lets attach a processor to an error handler
+        Processor errorHandler = routeContext.createProcessor(this);
+        ErrorHandlerBuilder builder = routeContext.getRoute().getErrorHandlerBuilder();
+        builder.addErrorHandlers(getExceptionClasses(), errorHandler);
     }
 
     @Override
@@ -113,4 +122,4 @@
         }
         return answer;
     }
-}
+}
\ No newline at end of file

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

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java?view=diff&rev=564295&r1=564294&r2=564295
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java Thu Aug  9 10:43:51 2007
@@ -421,21 +421,27 @@
 
     public InterceptType intercept() {
         InterceptType answer = new InterceptType();
-        getOutputs().add(answer);
+        addOutput(answer);
         return answer;
     }
 
     public ProcessorType proceed() {
-        getOutputs().add(new ProceedType());
+        addOutput(new ProceedType());
         return this;
     }
 
+    public ExceptionType exception(Class exceptionType) {
+        ExceptionType answer = new ExceptionType(exceptionType);
+        addOutput(answer);
+        return answer;
+    }
+
     /**
      * Apply an interceptor route if the predicate is true
      */
     public OtherwiseType intercept(Predicate predicate) {
         InterceptType answer = new InterceptType();
-        getOutputs().add(answer);
+        addOutput(answer);
         return answer.when(predicate);
     }
 

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesType.java?view=diff&rev=564295&r1=564294&r2=564295
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesType.java Thu Aug  9 10:43:51 2007
@@ -51,6 +51,8 @@
     @XmlTransient
     private List<InterceptType> intercepts = new ArrayList<InterceptType>();
     @XmlTransient
+    private List<ExceptionType> exceptions = new ArrayList<ExceptionType>();
+    @XmlTransient
     private CamelContext camelContext;
 
     @Override
@@ -90,6 +92,14 @@
         this.intercepts = intercepts;
     }
 
+    public List<ExceptionType> getExceptions() {
+        return exceptions;
+    }
+
+    public void setExceptions(List<ExceptionType> exceptions) {
+        this.exceptions = exceptions;
+    }
+
     public CamelContext getCamelContext() {
         return camelContext;
     }
@@ -139,6 +149,7 @@
         route.setInheritErrorHandlerFlag(getInheritErrorHandlerFlag());
         route.getInterceptors().addAll(getInterceptors());
         route.getOutputs().addAll(getIntercepts());
+        route.getOutputs().addAll(getExceptions());
         getRoutes().add(route);
         return route;
     }
@@ -160,4 +171,9 @@
         return answer.when(predicate);
     }
 
+    public ExceptionType exception(Class exceptionType) {
+        ExceptionType answer = new ExceptionType(exceptionType);
+        getExceptions().add(answer);
+        return answer;
+    }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TryType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TryType.java?view=diff&rev=564295&r1=564294&r2=564295
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TryType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TryType.java Thu Aug  9 10:43:51 2007
@@ -72,13 +72,13 @@
     // -------------------------------------------------------------------------
     public CatchType handle(Class<?> exceptionType) {
         CatchType answer = new CatchType(exceptionType);
-        getOutputs().add(answer);
+        addOutput(answer);
         return answer;
     }
 
     public FinallyType handleAll() {
         FinallyType answer = new FinallyType();
-        getOutputs().add(answer);
+        addOutput(answer);
         return answer;
     }
 

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java?view=diff&rev=564295&r1=564294&r2=564295
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DeadLetterChannel.java Thu Aug  9 10:43:51 2007
@@ -32,7 +32,7 @@
  *
  * @version $Revision$
  */
-public class DeadLetterChannel extends ServiceSupport implements ErrorHandler {
+public class DeadLetterChannel extends ErrorHandlerSupport {
     public static final String REDELIVERY_COUNTER = "org.apache.camel.RedeliveryCounter";
     public static final String REDELIVERED = "org.apache.camel.Redelivered";
 
@@ -77,7 +77,10 @@
             try {
                 output.process(exchange);
                 return;
-            } catch (RuntimeException e) {
+            } catch (Throwable e) {
+                if (customProcessorForException(exchange, e)) {
+                    return;
+                }
                 logger.log("On delivery attempt: " + redeliveryCounter + " caught: " + e, e);
             }
             redeliveryCounter = incrementRedeliveryCounter(exchange);

Added: 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?view=auto&rev=564295
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandlerSupport.java (added)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/ErrorHandlerSupport.java Thu Aug  9 10:43:51 2007
@@ -0,0 +1,66 @@
+/**
+ *
+ * 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.processor;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.ServiceSupport;
+
+import java.util.IdentityHashMap;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public abstract class ErrorHandlerSupport extends ServiceSupport implements ErrorHandler {
+    private Map<Class, Processor> exceptionHandlers = new IdentityHashMap<Class, Processor>();
+
+    public void addCustomProcessor(Class exceptionType, Processor processor) {
+        addChildService(processor);
+        exceptionHandlers.put(exceptionType, processor);
+
+    }
+
+    /**
+     * Attempts to invoke the handler for this particular exception if one is available
+     * @param exchange
+     * @param exception
+     * @return
+     */
+    protected boolean customProcessorForException(Exchange exchange, Throwable exception) throws Exception {
+        Processor processor = getProcessorForException(exchange, exception);
+        if (processor != null) {
+            exchange.setException(exception);
+            processor.process(exchange);
+            return true;
+        }
+        return false;
+    }
+
+    protected Processor getProcessorForException(Exchange exchange, Throwable exception) {
+        Set<Map.Entry<Class,Processor>> entries = exceptionHandlers.entrySet();
+        for (Map.Entry<Class, Processor> entry : entries) {
+            Class type = entry.getKey();
+            if (type.isInstance(exception)) {
+                return entry.getValue();
+            }
+        }
+        return null;
+    }
+}

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

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java?view=diff&rev=564295&r1=564294&r2=564295
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/LoggingErrorHandler.java Thu Aug  9 10:43:51 2007
@@ -28,7 +28,7 @@
  *
  * @version $Revision$
  */
-public class LoggingErrorHandler extends ServiceSupport implements ErrorHandler {
+public class LoggingErrorHandler extends ErrorHandlerSupport {
     private Processor output;
     private Log log;
     private LoggingLevel level;
@@ -51,8 +51,10 @@
     public void process(Exchange exchange) throws Exception {
         try {
             output.process(exchange);
-        } catch (RuntimeException e) {
-            logError(exchange, e);
+        } catch (Throwable e) {
+            if (!customProcessorForException(exchange, e)) {
+                logError(exchange, e);
+            }
         }
     }
 
@@ -84,7 +86,7 @@
 
     // Implementation methods
     // -------------------------------------------------------------------------
-    protected void logError(Exchange exchange, RuntimeException e) {
+    protected void logError(Exchange exchange, Throwable e) {
         switch (level) {
         case DEBUG:
             if (log.isDebugEnabled()) {
@@ -122,7 +124,7 @@
         }
     }
 
-    protected Object logMessage(Exchange exchange, RuntimeException e) {
+    protected Object logMessage(Exchange exchange, Throwable e) {
         return e + " while processing exchange: " + exchange;
     }
 

Modified: activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index?view=diff&rev=564295&r1=564294&r2=564295
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index (original)
+++ activemq/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index Thu Aug  9 10:43:51 2007
@@ -19,6 +19,7 @@
 CatchType
 ChoiceType
 DelayerType
+ExceptionType
 FilterType
 FinallyType
 FromType

Copied: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithExceptionTest.java (from r564133, activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationTest.java)
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithExceptionTest.java?view=diff&rev=564295&p1=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationTest.java&r1=564133&p2=activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithExceptionTest.java&r2=564295
==============================================================================
--- activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationTest.java (original)
+++ activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithExceptionTest.java Thu Aug  9 10:43:51 2007
@@ -16,53 +16,22 @@
  */
 package org.apache.camel.processor;
 
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.Processor;
 import org.apache.camel.ValidationException;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.component.mock.MockEndpoint;
 
 /**
  * @version $Revision: 1.1 $
  */
-public class ValidationTest extends ContextTestSupport {
-    protected Processor validator = new MyValidator();
-    protected MockEndpoint validEndpoint;
-    protected MockEndpoint invalidEndpoint;
-
-    public void testValidMessage() throws Exception {
-        validEndpoint.expectedMessageCount(1);
-
-        template.sendBodyAndHeader("direct:start", "<valid/>", "foo", "bar");
-
-        MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint);
-    }
-
-    public void testInvalidMessage() throws Exception {
-        invalidEndpoint.expectedMessageCount(1);
-
-        template.sendBodyAndHeader("direct:start", "<invalid/>", "foo", "notMatchedHeaderValue");
-
-        MockEndpoint.assertIsSatisfied(validEndpoint, invalidEndpoint);
-    }
-
-    @Override
-    protected void setUp() throws Exception {
-        super.setUp();
-
-        validEndpoint = resolveMandatoryEndpoint("mock:valid", MockEndpoint.class);
-        invalidEndpoint = resolveMandatoryEndpoint("mock:invalid", MockEndpoint.class);
-    }
-
+public class ValidationWithExceptionTest extends ValidationTest {
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
+                exception(ValidationException.class).to("mock:invalid");
+
                 from("direct:start").
-                        tryBlock().
-                            process(validator).
-                            to("mock:valid").
-                        handle(ValidationException.class).to("mock:invalid");
+                        process(validator).
+                        to("mock:valid");
             }
         };
     }
-}
+}
\ No newline at end of file

Propchange: activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ValidationWithExceptionTest.java
------------------------------------------------------------------------------
    svn:eol-style = native