camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1179342 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/processor/interceptor/ test/java/org/apache/camel/processor/async/ test/java/org/apache/camel/processor/interceptor/
Date Wed, 05 Oct 2011 17:33:34 GMT
Author: dkulp
Date: Wed Oct  5 17:33:34 2011
New Revision: 1179342

URL: http://svn.apache.org/viewvc?rev=1179342&view=rev
Log:
[CAMEL-4500] Make the traceHandlers list threadsafe and allow the
TraceInterceptor to use the live list (instead of a copy of it) to allow
dynamic changing of the tracers

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/async/AsyncTraceHandlerTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceHandlerTest.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=1179342&r1=1179341&r2=1179342&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 17:33:34 2011
@@ -17,6 +17,7 @@
 package org.apache.camel.processor.interceptor;
 
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
 import org.apache.camel.AsyncCallback;
@@ -72,8 +73,7 @@ public class TraceInterceptor extends De
         if (tracer.getFormatter() != null) {
             this.formatter = tracer.getFormatter();
         }
-        this.traceHandlers = new ArrayList<TraceEventHandler>();
-        this.traceHandlers.addAll(tracer.getTraceHandlers());
+        this.traceHandlers = tracer.getTraceHandlers();
     }
 
     @Override
@@ -367,7 +367,6 @@ public class TraceInterceptor extends De
 
     @Deprecated
     public void setTraceHandler(TraceEventHandler traceHandler) {
-        traceHandlers.clear();
-        traceHandlers.add(traceHandler);
+        traceHandlers = Collections.singletonList(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=1179342&r1=1179341&r2=1179342&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 17:33:34 2011
@@ -16,8 +16,8 @@
  */
 package org.apache.camel.processor.interceptor;
 
-import java.util.ArrayList;
 import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Endpoint;
@@ -54,11 +54,11 @@ public class Tracer implements Intercept
     private boolean useJpa;
     private CamelLogProcessor logger;
     private TraceInterceptorFactory traceInterceptorFactory = new DefaultTraceInterceptorFactory();
-    private List<TraceEventHandler> traceHandlers;
+    private CopyOnWriteArrayList<TraceEventHandler> traceHandlers;
     private String jpaTraceEventMessageClassName = JPA_TRACE_EVENT_MESSAGE;
     
     public Tracer() {
-        traceHandlers = new ArrayList<TraceEventHandler>();
+        traceHandlers = new CopyOnWriteArrayList<TraceEventHandler>();
         traceHandlers.add(new DefaultTraceEventHandler(this));
     }
 

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncTraceHandlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncTraceHandlerTest.java?rev=1179342&r1=1179341&r2=1179342&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncTraceHandlerTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/async/AsyncTraceHandlerTest.java
Wed Oct  5 17:33:34 2011
@@ -51,7 +51,8 @@ public class AsyncTraceHandlerTest exten
 
         Tracer tracer = (Tracer) contextLocal.getDefaultTracer();
         tracer.setEnabled(true);
-        tracer.setTraceHandler(new MyTraceHandler());
+        tracer.getTraceHandlers().clear();
+        tracer.getTraceHandlers().add(new MyTraceHandler());
         tracer.setTraceOutExchanges(true);
 
         return contextLocal;

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceHandlerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceHandlerTest.java?rev=1179342&r1=1179341&r2=1179342&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceHandlerTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/TraceHandlerTest.java
Wed Oct  5 17:33:34 2011
@@ -31,14 +31,15 @@ public class TraceHandlerTest extends Tr
         Tracer tracer = (Tracer) contextLocal.getDefaultTracer();
         tracer.setEnabled(true);
         tracer.setTraceExceptions(true);
-        tracer.setTraceHandler(new TraceHandlerTestHandler(tracedMessages));
+        tracer.getTraceHandlers().clear();
+        tracer.getTraceHandlers().add(new TraceHandlerTestHandler(tracedMessages));
 
         return contextLocal;
     }
 
     @Override
     protected void prepareTestTracerExceptionInOut() {
-        ((TraceHandlerTestHandler) ((Tracer) context.getDefaultTracer()).getTraceHandler()).setTraceAllNodes(true);
+        ((TraceHandlerTestHandler) ((Tracer) context.getDefaultTracer()).getTraceHandlers().get(0)).setTraceAllNodes(true);
     }
 
 }

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=1179342&r1=1179341&r2=1179342&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 17:33:34 2011
@@ -35,7 +35,9 @@ public class TraceInterceptorFactoryCrea
             this.traceAllNodes = traceAllNodes;
         }
 
+        @SuppressWarnings("deprecation")
         public Processor createTraceInterceptor(ProcessorDefinition node, Processor target,
TraceFormatter formatter, Tracer tracer) {
+            
             TraceInterceptor interceptor = new TraceInterceptor(node, target, formatter,
tracer);
 
             while (target instanceof DelegateProcessor) {



Mime
View raw message