You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ha...@apache.org on 2011/06/09 20:34:18 UTC

svn commit: r1134029 - in /camel/branches/camel-2.7.x: ./ camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/main/java/org/apache/camel/spi/ camel-core/src/test/java/org/apache/camel/impl/ camel-core/src/test/java/org/apache/camel/mana...

Author: hadrian
Date: Thu Jun  9 18:34:18 2011
New Revision: 1134029

URL: http://svn.apache.org/viewvc?rev=1134029&view=rev
Log:
CAMEL-3928. Port to 2.7.x

Added:
    camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/processor/interceptor/CustomInterceptorRouteWithChildOutputTest.java
      - copied unchanged from r1099417, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/interceptor/CustomInterceptorRouteWithChildOutputTest.java
Modified:
    camel/branches/camel-2.7.x/   (props changed)
    camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/processor/DefaultChannel.java
    camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/spi/ExceptionHandler.java
    camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/spi/NodeIdFactory.java
    camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/impl/CustomIdFactoryTest.java
    camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationCustomMBeanTest.java
    camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java
    camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugExceptionBreakpointTest.java
    camel/branches/camel-2.7.x/components/camel-http/   (props changed)

Propchange: camel/branches/camel-2.7.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jun  9 18:34:18 2011
@@ -1 +1 @@
-/camel/trunk:1083696,1087276,1087612,1087856,1088583,1088916-1088917,1089275,1090166,1091518,1091771,1091799,1092068,1092577,1092667,1093978,1095405,1095469,1095471,1095475-1095476,1102162,1104076,1124497,1131411
+/camel/trunk:1083696,1087276,1087612,1087856,1088583,1088916-1088917,1089275,1090166,1091518,1091771,1091799,1092068,1092577,1092667,1093978,1095405,1095469,1095471,1095475-1095476,1099417,1102162,1104076,1124497,1131411

Modified: camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/processor/DefaultChannel.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/processor/DefaultChannel.java?rev=1134029&r1=1134028&r2=1134029&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/processor/DefaultChannel.java (original)
+++ camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/processor/DefaultChannel.java Thu Jun  9 18:34:18 2011
@@ -165,17 +165,19 @@ public class DefaultChannel extends Serv
             ((CamelContextAware) target).setCamelContext(camelContext);
         }
 
+        // the definition to wrap should be the fine grained,
+        // so if a child is set then use it, if not then its the original output used
+        ProcessorDefinition<?> targetOutputDef = childDefinition != null ? childDefinition : outputDefinition;
+
         // first wrap the output with the managed strategy if any
         InterceptStrategy managed = routeContext.getManagedInterceptStrategy();
         if (managed != null) {
             next = target == nextProcessor ? null : nextProcessor;
-            target = managed.wrapProcessorInInterceptors(routeContext.getCamelContext(), outputDefinition, target, next);
+            target = managed.wrapProcessorInInterceptors(routeContext.getCamelContext(), targetOutputDef, target, next);
         }
 
         // then wrap the output with the tracer
-        // the tracer should have the fine grained definition so if a child is set then use it, if not then its the original output used
-        ProcessorDefinition<?> traceDef = childDefinition != null ? childDefinition : outputDefinition;
-        TraceInterceptor trace = (TraceInterceptor) getOrCreateTracer().wrapProcessorInInterceptors(routeContext.getCamelContext(), traceDef, target, null);
+        TraceInterceptor trace = (TraceInterceptor) getOrCreateTracer().wrapProcessorInInterceptors(routeContext.getCamelContext(), targetOutputDef, target, null);
         // trace interceptor need to have a reference to route context so we at runtime can enable/disable tracing on-the-fly
         trace.setRouteContext(routeContext);
         target = trace;
@@ -191,7 +193,8 @@ public class DefaultChannel extends Serv
             if (strategy instanceof Tracer) {
                 continue;
             }
-            Processor wrapped = strategy.wrapProcessorInInterceptors(routeContext.getCamelContext(), outputDefinition, target, next);
+            // use the fine grained definition (eg the child if available). Its always possible to get back to the parent
+            Processor wrapped = strategy.wrapProcessorInInterceptors(routeContext.getCamelContext(), targetOutputDef, target, next);
             if (!(wrapped instanceof AsyncProcessor)) {
                 LOG.warn("Interceptor: " + strategy + " at: " + outputDefinition + " does not return an AsyncProcessor instance."
                         + " This causes the asynchronous routing engine to not work as optimal as possible."
@@ -202,7 +205,7 @@ public class DefaultChannel extends Serv
                 // use a bridge and wrap again which allows us to adapt and leverage the asynchronous routing engine anyway
                 // however its not the most optimal solution, but we can still run.
                 InterceptorToAsyncProcessorBridge bridge = new InterceptorToAsyncProcessorBridge(target);
-                wrapped = strategy.wrapProcessorInInterceptors(routeContext.getCamelContext(), outputDefinition, bridge, next);
+                wrapped = strategy.wrapProcessorInInterceptors(routeContext.getCamelContext(), targetOutputDef, bridge, next);
                 bridge.setTarget(wrapped);
                 wrapped = bridge;
             }

Modified: camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/spi/ExceptionHandler.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/spi/ExceptionHandler.java?rev=1134029&r1=1134028&r2=1134029&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/spi/ExceptionHandler.java (original)
+++ camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/spi/ExceptionHandler.java Thu Jun  9 18:34:18 2011
@@ -20,6 +20,9 @@ import org.apache.camel.Exchange;
 
 /**
  * A Strategy pattern for handling exceptions; particularly in asynchronous processes such as consumers
+ * <p/>
+ * Its important to <b>not</b> throw any exceptions when handling exceptions as they handler
+ * is often invoked in a try .. catch logic already
  *
  * @version 
  */

Modified: camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/spi/NodeIdFactory.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/spi/NodeIdFactory.java?rev=1134029&r1=1134028&r2=1134029&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/spi/NodeIdFactory.java (original)
+++ camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/spi/NodeIdFactory.java Thu Jun  9 18:34:18 2011
@@ -26,9 +26,10 @@ import org.apache.camel.model.OptionalId
 public interface NodeIdFactory {
 
     /**
-     * Creates an id for the given model definiton.
+     * Creates an id for the given model definition.
      *
      * @param definition model definition
+     *        (its most likely a {@link org.apache.camel.model.OutputDefinition OutputDefinition} instance)
      * @return the id created
      */
     String createId(OptionalIdentifiedDefinition<?> definition);

Modified: camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/impl/CustomIdFactoryTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/impl/CustomIdFactoryTest.java?rev=1134029&r1=1134028&r2=1134029&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/impl/CustomIdFactoryTest.java (original)
+++ camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/impl/CustomIdFactoryTest.java Thu Jun  9 18:34:18 2011
@@ -71,6 +71,7 @@ public class CustomIdFactoryTest extends
                         .when(body().contains("Hello"))
                             .to("mock:hello")
                         .otherwise()
+                            .log("Hey")
                             .to("mock:other")
                     .end();
             }
@@ -87,8 +88,8 @@ public class CustomIdFactoryTest extends
         template.sendBody("direct:start", "Hello World");
         assertMockEndpointsSatisfied();
 
-        // this should take the when path
-        assertEquals("#choice6##when3#", ids);
+        // this should take the when path (first to)
+        assertEquals("#choice5##to2#", ids);
     }
 
     /**
@@ -102,7 +103,7 @@ public class CustomIdFactoryTest extends
         assertMockEndpointsSatisfied();
 
         // this should take the otherwise path
-        assertEquals("#choice6##otherwise5#", ids);
+        assertEquals("#choice5##log3##to4#", ids);
     }
 
     private class MyDebuggerCheckingId implements InterceptStrategy {

Modified: camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationCustomMBeanTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationCustomMBeanTest.java?rev=1134029&r1=1134028&r2=1134029&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationCustomMBeanTest.java (original)
+++ camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationCustomMBeanTest.java Thu Jun  9 18:34:18 2011
@@ -100,7 +100,7 @@ public class JmxInstrumentationCustomMBe
         assertEquals("Could not find 1 context: " + s, 1, s.size());
 
         s = CastUtils.cast(mbsc.queryNames(new ObjectName(domainName + ":type=processors,*"), null));
-        assertEquals("Could not find 1 processors: " + s, 1, s.size());
+        assertEquals("Could not find 1 processors: " + s, 2, s.size());
 
         s = CastUtils.cast(mbsc.queryNames(new ObjectName(domainName + ":type=routes,*"), null));
         assertEquals("Could not find 1 route: " + s, 1, s.size());

Modified: camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java?rev=1134029&r1=1134028&r2=1134029&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java (original)
+++ camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/management/JmxInstrumentationUsingDefaultsTest.java Thu Jun  9 18:34:18 2011
@@ -69,7 +69,7 @@ public class JmxInstrumentationUsingDefa
         assertEquals("Could not find 1 context: " + s, 1, s.size());
 
         s = mbsc.queryNames(new ObjectName(domainName + ":type=processors,*"), null);
-        assertEquals("Could not find 1 processors: " + s, 1, s.size());
+        assertEquals("Could not find 1 processors: " + s, 2, s.size());
 
         s = mbsc.queryNames(new ObjectName(domainName + ":type=consumers,*"), null);
         assertEquals("Could not find 1 consumers: " + s, 1, s.size());

Modified: camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugExceptionBreakpointTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugExceptionBreakpointTest.java?rev=1134029&r1=1134028&r2=1134029&view=diff
==============================================================================
--- camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugExceptionBreakpointTest.java (original)
+++ camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/processor/interceptor/DebugExceptionBreakpointTest.java Thu Jun  9 18:34:18 2011
@@ -75,7 +75,7 @@ public class DebugExceptionBreakpointTes
         assertMockEndpointsSatisfied();
 
         assertEquals(2, logs.size());
-        assertEquals("Breakpoint at when caused by: IllegalArgumentException[Damn]", logs.get(0));
+        assertEquals("Breakpoint at throwException caused by: IllegalArgumentException[Damn]", logs.get(0));
         assertEquals("Breakpoint at choice caused by: IllegalArgumentException[Damn]", logs.get(1));
     }
 

Propchange: camel/branches/camel-2.7.x/components/camel-http/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Thu Jun  9 18:34:18 2011
@@ -1 +1 @@
-/camel/trunk/components/camel-http:917526,1083696,1087276,1087612,1087856,1088583,1088916-1088917,1089275,1090166,1091518,1091771,1091799,1092068,1092577,1092667,1093978,1095405,1095469,1095471,1095475-1095476,1102162,1104076,1124497,1131411
+/camel/trunk/components/camel-http:917526,1083696,1087276,1087612,1087856,1088583,1088916-1088917,1089275,1090166,1091518,1091771,1091799,1092068,1092577,1092667,1093978,1095405,1095469,1095471,1095475-1095476,1099417,1102162,1104076,1124497,1131411