camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject svn commit: r1179291 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/processor/interceptor/ test/java/org/apache/camel/processor/interceptor/
Date Wed, 05 Oct 2011 16:12:55 GMT
Author: cschneider
Date: Wed Oct  5 16:12:55 2011
New Revision: 1179291

URL: http://svn.apache.org/viewvc?rev=1179291&view=rev
Log:
CAMEL-4500 Bugfix for handling more than one handler and for changing the handler of an interceptor

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceInterceptorFactoryCreatesHandlerTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java?rev=1179291&r1=1179290&r2=1179291&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
Wed Oct  5 16:12:55 2011
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.processor.interceptor;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
@@ -58,6 +61,7 @@ public class TraceInterceptor extends De
     private TraceFormatter formatter;
 
     private RouteContext routeContext;
+    private List<TraceEventHandler> traceHandlers;
 
     public TraceInterceptor(ProcessorDefinition<?> node, Processor target, TraceFormatter
formatter, Tracer tracer) {
         super(target);
@@ -68,6 +72,8 @@ public class TraceInterceptor extends De
         if (tracer.getFormatter() != null) {
             this.formatter = tracer.getFormatter();
         }
+        this.traceHandlers = new ArrayList<TraceEventHandler>();
+        this.traceHandlers.addAll(tracer.getTraceHandlers());
     }
 
     @Override
@@ -281,14 +287,14 @@ public class TraceInterceptor extends De
     }
 
     protected void traceExchange(Exchange exchange) throws Exception {
-        for (TraceEventHandler traceHandler : tracer.getTraceHandlers()) {
+        for (TraceEventHandler traceHandler : traceHandlers) {
             traceHandler.traceExchange(node, processor, this, exchange);
         }
     }
 
     protected Object traceExchangeIn(Exchange exchange) throws Exception {
         Object result = null;
-        for (TraceEventHandler traceHandler : tracer.getTraceHandlers()) {
+        for (TraceEventHandler traceHandler : traceHandlers) {
             Object result1 = traceHandler.traceExchangeIn(node, processor, this, exchange);
             if (result1 != null) {
                 result = result1;
@@ -298,7 +304,7 @@ public class TraceInterceptor extends De
     }
 
     protected void traceExchangeOut(Exchange exchange, Object traceState) throws Exception
{
-        for (TraceEventHandler traceHandler : tracer.getTraceHandlers()) {
+        for (TraceEventHandler traceHandler : traceHandlers) {
             traceHandler.traceExchangeOut(node, processor, this, exchange, traceState);
         }
     }
@@ -350,12 +356,18 @@ public class TraceInterceptor extends De
     @Override
     protected void doStart() throws Exception {
         super.doStart();
-        ServiceHelper.startService(tracer.getTraceHandlers());
+        ServiceHelper.startService(traceHandlers);
     }
 
     @Override
     protected void doStop() throws Exception {
         super.doStop();
-        ServiceHelper.stopService(tracer.getTraceHandlers());
+        ServiceHelper.stopService(traceHandlers);
+    }
+
+    @Deprecated
+    public void setTraceHandler(TraceEventHandler traceHandler) {
+        traceHandlers.clear();
+        traceHandlers.add(traceHandler);
     }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java?rev=1179291&r1=1179290&r2=1179291&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Tracer.java
Wed Oct  5 16:12:55 2011
@@ -308,7 +308,8 @@ public class Tracer implements Intercept
      */
     @Deprecated
     public void setTraceHandler(TraceEventHandler traceHandler) {
-        this.traceHandlers.add(0, traceHandler);
+        this.traceHandlers.clear();
+        this.traceHandlers.add(traceHandler);
     }
     
     /**

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceInterceptorFactoryCreatesHandlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceInterceptorFactoryCreatesHandlerTest.java?rev=1179291&r1=1179290&r2=1179291&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceInterceptorFactoryCreatesHandlerTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceInterceptorFactoryCreatesHandlerTest.java
Wed Oct  5 16:12:55 2011
@@ -44,7 +44,7 @@ public class TraceInterceptorFactoryCrea
             if (traceAllNodes || !target.getClass().equals(TraceTestProcessor.class)) {
                 TraceHandlerTestHandler traceHandler = new TraceHandlerTestHandler(eventMessages);
                 traceHandler.setTraceAllNodes(true);
-                tracer.addTraceHandler(traceHandler);
+                interceptor.setTraceHandler(traceHandler);
             }
 
             return interceptor;



Mime
View raw message