camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r761894 - in /camel/trunk/camel-core/src/main/java/org/apache/camel: builder/ impl/ management/ model/ spi/
Date Sat, 04 Apr 2009 10:46:19 GMT
Author: davsclaus
Date: Sat Apr  4 10:46:18 2009
New Revision: 761894

URL: http://svn.apache.org/viewvc?rev=761894&view=rev
Log:
CAMEL-1511: Preparing for TransactionErrorHandler improvements

Modified:
    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/impl/DefaultErrorHandlerWrappingStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/NoPolicy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationErrorHandlerWrappingStrategy.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/PolicyDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Policy.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=761894&r1=761893&r2=761894&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
Sat Apr  4 10:46:18 2009
@@ -46,6 +46,13 @@
 
     public Processor createErrorHandler(RouteContext routeContext, Processor processor) throws
Exception {
         if (handler == null) {
+            handler = lookupErrorHandlerBuilder(routeContext);
+        }
+        return handler.createErrorHandler(routeContext, processor);
+    }
+
+    public ErrorHandlerBuilder lookupErrorHandlerBuilder(RouteContext routeContext) {
+        if (handler == null) {
             handler = routeContext.lookup(ref, ErrorHandlerBuilder.class);
             ObjectHelper.notNull(handler, "error handler '" + ref + "'");
             List<OnExceptionDefinition> list = getExceptions();
@@ -53,6 +60,11 @@
                 handler.addErrorHandlers(exceptionType);
             }
         }
-        return handler.createErrorHandler(routeContext, processor);
+        return handler;
+    }
+
+    public String getRef() {
+        return ref;
     }
+
 }

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=761894&r1=761893&r2=761894&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
Sat Apr  4 10:46:18 2009
@@ -31,10 +31,13 @@
     private List<OnExceptionDefinition> exceptions = new ArrayList<OnExceptionDefinition>();
 
     public void addErrorHandlers(OnExceptionDefinition exception) {
-        exceptions.add(exception);
+        // only add if we not already have it
+        if (!exceptions.contains(exception)) {
+            exceptions.add(exception);
+        }
     }
 
-    protected void configure(ErrorHandlerSupport handler) {
+    public void configure(ErrorHandlerSupport handler) {
         for (OnExceptionDefinition exception : exceptions) {
             handler.addExceptionPolicy(exception);
         }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultErrorHandlerWrappingStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultErrorHandlerWrappingStrategy.java?rev=761894&r1=761893&r2=761894&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultErrorHandlerWrappingStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultErrorHandlerWrappingStrategy.java
Sat Apr  4 10:46:18 2009
@@ -20,6 +20,7 @@
 
 import org.apache.camel.Processor;
 import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.processor.ErrorHandler;
 import org.apache.camel.spi.ErrorHandlerWrappingStrategy;
 import org.apache.camel.spi.RouteContext;
 
@@ -39,6 +40,10 @@
     }
 
     public Processor wrapProcessorInErrorHandler(ProcessorDefinition processorDefinition,
Processor target) throws Exception {
+        // dont double wrap error handlers
+        if (target instanceof ErrorHandler) {
+            return target;
+        }
 
         // don't wrap our instrumentation interceptors
         if (counterList.contains(processorDefinition)) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/NoPolicy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/NoPolicy.java?rev=761894&r1=761893&r2=761894&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/NoPolicy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/NoPolicy.java Sat Apr  4 10:46:18
2009
@@ -18,15 +18,16 @@
 
 import org.apache.camel.Processor;
 import org.apache.camel.spi.Policy;
+import org.apache.camel.spi.RouteContext;
 
 /**
  * Represents an {@link Policy} which adds no interceptors.
  *
  * @version $Revision$
  */
-public class NoPolicy<E> implements Policy<E> {
+public class NoPolicy implements Policy {
 
-    public Processor wrap(Processor processor) {
+    public Processor wrap(RouteContext routeContext, Processor processor) {
         return processor;
     }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationErrorHandlerWrappingStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationErrorHandlerWrappingStrategy.java?rev=761894&r1=761893&r2=761894&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationErrorHandlerWrappingStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationErrorHandlerWrappingStrategy.java
Sat Apr  4 10:46:18 2009
@@ -20,6 +20,7 @@
 
 import org.apache.camel.Processor;
 import org.apache.camel.model.ProcessorDefinition;
+import org.apache.camel.processor.ErrorHandler;
 import org.apache.camel.spi.ErrorHandlerWrappingStrategy;
 import org.apache.camel.spi.RouteContext;
 
@@ -37,6 +38,10 @@
     }
 
     public Processor wrapProcessorInErrorHandler(ProcessorDefinition processorType, Processor
target) throws Exception {
+        // dont double wrap error handlers
+        if (target instanceof ErrorHandler) {
+            return target;
+        }
 
         // don't wrap our instrumentation interceptors
         if (counterMap.containsKey(processorType)) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/PolicyDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/PolicyDefinition.java?rev=761894&r1=761893&r2=761894&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/PolicyDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/PolicyDefinition.java Sat
Apr  4 10:46:18 2009
@@ -82,7 +82,7 @@
 
         Policy policy = resolvePolicy(routeContext);
         ObjectHelper.notNull(policy, "policy", this);
-        return policy.wrap(childProcessor);
+        return policy.wrap(routeContext, childProcessor);
     }
 
     protected Policy resolvePolicy(RouteContext routeContext) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Policy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Policy.java?rev=761894&r1=761893&r2=761894&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Policy.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/Policy.java Sat Apr  4 10:46:18
2009
@@ -23,13 +23,14 @@
  *
  * @version $Revision$
  */
-public interface Policy<E> {
+public interface Policy {
 
     /**
      * Wraps any applicable interceptors around the given processor
      *
+     * @param routeContext the route context
      * @param processor the processor to be intercepted
      * @return either the original processor or a processor wrapped in one or more interceptors
      */
-    Processor wrap(Processor processor);
+    Processor wrap(RouteContext routeContext, Processor processor);
 }



Mime
View raw message