camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r788578 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/ main/java/org/apache/camel/component/dataset/ main/java/org/apache/camel/impl/ test/java/org/apache/camel/component/seda/ test/java/org/apache/camel/processor/
Date Fri, 26 Jun 2009 05:15:10 GMT
Author: davsclaus
Date: Fri Jun 26 05:15:09 2009
New Revision: 788578

URL: http://svn.apache.org/viewvc?rev=788578&view=rev
Log:
CAMEL-1759 easier configuration of tracing from Java DSL

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/Channel.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetSupport.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaComplexInOutTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DefaultErrorHandlerOnExceptionTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitWithEndTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java?rev=788578&r1=788577&r2=788578&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java Fri Jun 26 05:15:09
2009
@@ -469,4 +469,17 @@
      * @param cache whether stream caching is enabled or not
      */
     void setStreamCaching(Boolean cache);
+
+    /**
+     * Sets whether tracing is enabled or not (default is disabled).
+     * <p/>
+     * Will use the default trace formatter.
+     * <p/>
+     * Use {@link this#addInterceptStrategy(org.apache.camel.spi.InterceptStrategy)} if you
+     * want to add a custom {@link org.apache.camel.processor.interceptor.Tracer} where you
+     * can custome the tracing options and formatting as you like.
+     *
+     * @param tracing whether tracing is enabled or not.
+     */
+    void setTracing(Boolean tracing);
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/Channel.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/Channel.java?rev=788578&r1=788577&r2=788578&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/Channel.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/Channel.java Fri Jun 26 05:15:09
2009
@@ -109,6 +109,8 @@
 
     /**
      * Gets the defintion of the next processor
+     *
+     * @return the processor definition
      */
     ProcessorDefinition getProcessorDefinition();
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetSupport.java?rev=788578&r1=788577&r2=788578&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetSupport.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/component/dataset/DataSetSupport.java
Fri Jun 26 05:15:09 2009
@@ -78,6 +78,10 @@
         if (reportCount <= 0) {
             reportCount = getSize() / 5;
         }
+        // report cannot be 0 then default to the size
+        if (reportCount == 0) {
+            reportCount = getSize();
+        }
         return reportCount;
     }
 
@@ -124,4 +128,4 @@
      */
     protected void populateDefaultHeaders(Map<String, Object> map) {
     }
-}
\ No newline at end of file
+}

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java?rev=788578&r1=788577&r2=788578&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultCamelContext.java Fri
Jun 26 05:15:09 2009
@@ -754,6 +754,22 @@
         this.streamCache = cache;
     }
 
+    public void setTracing(Boolean tracing) {
+        // look if alredy enabled
+        Tracer tracer = Tracer.getTracer(this);
+        if (tracing && tracer == null) {
+            // not already enabled
+            addInterceptStrategy(new Tracer());
+        } else if (tracer != null) {
+            // disable existing tracer
+            for (InterceptStrategy strategy : interceptStrategies) {
+                if (strategy instanceof Tracer) {
+                    interceptStrategies.remove(strategy);
+                }
+            }
+        }
+    }
+
     /**
      * Returns true if handle fault has been enabled
      */

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaComplexInOutTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaComplexInOutTest.java?rev=788578&r1=788577&r2=788578&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaComplexInOutTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/component/seda/SedaComplexInOutTest.java
Fri Jun 26 05:15:09 2009
@@ -18,7 +18,6 @@
 
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
-import org.apache.camel.processor.interceptor.Tracer;
 
 /**
  * @version $Revision$
@@ -31,7 +30,6 @@
         String out = template.requestBody("direct:start", "Hello World", String.class);
         assertEquals("Bye World", out);
 
-
         assertMockEndpointsSatisfied();
     }
 
@@ -40,7 +38,7 @@
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                getContext().addInterceptStrategy(new Tracer());
+                getContext().setTracing(true);
 
                 from("direct:start").to("seda:a");
 
@@ -51,4 +49,4 @@
             }
         };
     }
-}
\ No newline at end of file
+}

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DefaultErrorHandlerOnExceptionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DefaultErrorHandlerOnExceptionTest.java?rev=788578&r1=788577&r2=788578&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DefaultErrorHandlerOnExceptionTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/DefaultErrorHandlerOnExceptionTest.java
Fri Jun 26 05:15:09 2009
@@ -52,7 +52,9 @@
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                onException(IllegalArgumentException.class).handled(true).to("mock:boom");
+                context.setTracing(true);
+
+                onException(IllegalArgumentException.class).handled(true).to("log:boom").to("mock:boom");
 
                 from("direct:start").process(new Processor() {
                     public void process(Exchange exchange) throws Exception {

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java?rev=788578&r1=788577&r2=788578&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RoutePerformanceTest.java
Fri Jun 26 05:15:09 2009
@@ -76,7 +76,7 @@
             public void configure() throws Exception {
                 from("dataset:foo").to("direct:start");
 
-                from("direct:start").to("direct:a", "direct:b", "direct:c");
+                from("direct:start").to("log:a?level=OFF", "log:b?level=OFF", "direct:c");
                 from("direct:c")
                     .choice()
                         .when().header("foo").to("mock:results", "dataset:foo")

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitWithEndTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitWithEndTest.java?rev=788578&r1=788577&r2=788578&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitWithEndTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitWithEndTest.java
Fri Jun 26 05:15:09 2009
@@ -48,10 +48,10 @@
     }
 
     public void testSplit() throws Exception {
-        getMockEndpoint("mock:start").expectedBodiesReceived("Hello,World");
-        getMockEndpoint("mock:last").expectedBodiesReceived("last hi Hello@hi World");
+        getMockEndpoint("mock:start").expectedBodiesReceived("Hello,World,Moon");
+        getMockEndpoint("mock:last").expectedBodiesReceived("last hi Hello@hi World@hi Moon");
 
-        template.sendBody("direct:start", "Hello,World");
+        template.sendBody("direct:start", "Hello,World,Moon");
 
         assertMockEndpointsSatisfied();
     }
@@ -62,6 +62,8 @@
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
+                context.setTracing(true);
+
                 MySplitBean bean = new MySplitBean();
 
                 from("direct:start")
@@ -78,7 +80,7 @@
                                     return newExchange;
                                 }
                             })
-                        .bean(bean, "hi").to("mock:split")
+                        .bean(bean, "hi").to("mock:split").to("log:foo")
                     .end()
                     .transform(body().prepend("last "))
                     .to("mock:last");
@@ -94,4 +96,4 @@
 
     }
 
-}
\ No newline at end of file
+}



Mime
View raw message