You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2013/01/25 08:23:37 UTC

svn commit: r1438365 - in /camel/branches/camel-2.9.x: ./ camel-core/src/main/java/org/apache/camel/impl/DefaultRouteNode.java camel-core/src/test/java/org/apache/camel/processor/SimpleProcessorTraceableTest.java

Author: davsclaus
Date: Fri Jan 25 07:23:37 2013
New Revision: 1438365

URL: http://svn.apache.org/viewvc?rev=1438365&view=rev
Log:
CAMEL-5995: Improved trace logic to look for traceable in wrapped/delegate processors.

Added:
    camel/branches/camel-2.9.x/camel-core/src/test/java/org/apache/camel/processor/SimpleProcessorTraceableTest.java
      - copied unchanged from r1438364, camel/branches/camel-2.10.x/camel-core/src/test/java/org/apache/camel/processor/SimpleProcessorTraceableTest.java
Modified:
    camel/branches/camel-2.9.x/   (props changed)
    camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteNode.java

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1438363
  Merged /camel/branches/camel-2.10.x:r1438364

Propchange: camel/branches/camel-2.9.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteNode.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteNode.java?rev=1438365&r1=1438364&r2=1438365&view=diff
==============================================================================
--- camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteNode.java (original)
+++ camel/branches/camel-2.9.x/camel-core/src/main/java/org/apache/camel/impl/DefaultRouteNode.java Fri Jan 25 07:23:37 2013
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.impl;
 
+import org.apache.camel.DelegateProcessor;
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
@@ -52,26 +53,40 @@ public class DefaultRouteNode implements
         return processorDefinition;
     }
 
-    @SuppressWarnings("deprecation")
     public String getLabel(Exchange exchange) {
         if (expression != null) {
             return expression.evaluate(exchange, String.class);
         }
 
-        Processor target = processor;
-        if (target != null && target instanceof Traceable) {
+        String label = getTraceLabel(processor);
+        if (label == null) {
+            // no label then default to use the definition label
+            label = processorDefinition.getLabel();
+        }
+        return label;
+    }
+
+    @SuppressWarnings("deprecation")
+    private String getTraceLabel(Processor target) {
+        if (target == null) {
+            return null;
+        }
+
+        if (target instanceof Traceable) {
             Traceable trace = (Traceable) target;
             return trace.getTraceLabel();
-        }
-        
-        // Compatiblity for old Traceable interface
-        if (target != null && target instanceof org.apache.camel.processor.Traceable) {
+        } else if (target instanceof org.apache.camel.processor.Traceable) {
+            // to be backwards compatible
             org.apache.camel.processor.Traceable trace = (org.apache.camel.processor.Traceable) target;
             return trace.getTraceLabel();
         }
 
-        // default then to definition
-        return processorDefinition.getLabel();
+        // if we are a delegate then drill down
+        if (target instanceof DelegateProcessor) {
+            return getTraceLabel(((DelegateProcessor) target).getProcessor());
+        }
+
+        return null;
     }
 
     public boolean isAbstract() {