camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r682255 - in /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor: DebugInterceptor.java Debugger.java
Date Mon, 04 Aug 2008 04:38:34 GMT
Author: ningjiang
Date: Sun Aug  3 21:38:33 2008
New Revision: 682255

URL: http://svn.apache.org/viewvc?rev=682255&view=rev
Log:
CAMEL-779 support to configure the debugger dynamically

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DebugInterceptor.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DebugInterceptor.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DebugInterceptor.java?rev=682255&r1=682254&r2=682255&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DebugInterceptor.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DebugInterceptor.java
Sun Aug  3 21:38:33 2008
@@ -37,6 +37,7 @@
     private Predicate traceFilter;
     private Breakpoint breakpoint = new Breakpoint();
     private boolean traceExceptions = true;
+    private boolean enabled = true;
 
     public DebugInterceptor(ProcessorType node, Processor target, List<Exchange> exchanges,
List<ExceptionEvent> exceptions) {
         super(target);
@@ -51,8 +52,10 @@
     }
 
     public void process(Exchange exchange) throws Exception {
-        checkForBreakpoint(exchange);
-        addTraceExchange(exchange);
+        if (isEnabled()) {
+            checkForBreakpoint(exchange);
+            addTraceExchange(exchange);
+        }
         try {
             super.proceed(exchange);
         } catch (Exception e) {
@@ -68,6 +71,14 @@
         return node;
     }
 
+    public boolean isEnabled() {
+        return enabled;
+    }
+
+    public void setEnabled(boolean flag) {
+        enabled = flag;
+    }
+
     public List<Exchange> getExchanges() {
         return exchanges;
     }
@@ -114,7 +125,7 @@
     }
 
     private boolean shouldTraceExceptionEvents(Exchange exchange, Throwable e) {
-        return isTraceExceptions();
+        return isTraceExceptions() && isEnabled();
     }
 
     /**

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java?rev=682255&r1=682254&r2=682255&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java
(original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java
Sun Aug  3 21:38:33 2008
@@ -41,7 +41,8 @@
     private int exchangeBufferSize = -1;
     private Map<String, DebugInterceptor> interceptors = new HashMap<String, DebugInterceptor>();
     private boolean logExchanges = true;
-    private TraceFormatter formatter = new TraceFormatter();
+    private boolean enabled = true;
+    private Tracer tracer = new Tracer();
 
 
     /**
@@ -63,10 +64,12 @@
         return null;
     }
 
+
     public DebugInterceptor getInterceptor(String id) {
         return interceptors.get(id);
     }
 
+
     /**
      * Returns the list of exchanges sent to the given node in the DSL
      */
@@ -79,6 +82,18 @@
         }
     }
 
+    public void setEnable(boolean flag) {
+        enabled = flag;
+        tracer.setEnabled(flag);
+        for(DebugInterceptor interceptor : interceptors.values()) {
+            interceptor.setEnabled(flag);
+        }
+    }
+
+    public boolean isEnabled() {
+        return enabled;
+    }
+
     /**
      * Returns the breakpoint object for the given node in the DSL
      */
@@ -91,11 +106,24 @@
         }
     }
 
+    public TraceFormatter getTraceFormatter() {
+        return tracer.getFormatter();
+    }
+
+    public void setTraceFormatter(TraceFormatter formatter) {
+        tracer.setFormatter(formatter);
+    }
+
+    public void setLogExchanges(boolean flag) {
+        logExchanges = flag;
+    }
+
 
     public Processor wrapProcessorInInterceptors(ProcessorType processorType, Processor target)
throws Exception {
         String id = processorType.idOrCreate();
         if (logExchanges) {
-            target = new TraceInterceptor(processorType, target, formatter);
+            TraceInterceptor  traceInterceptor= new TraceInterceptor(processorType, target,
tracer);
+            target = traceInterceptor;
         }
         DebugInterceptor interceptor = new DebugInterceptor(processorType, target, createExchangeList(),
createExceptionsList());
         interceptors.put(id, interceptor);
@@ -120,4 +148,6 @@
         // TODO allow some kinda LRU based fixed size list to be used?
         return new ArrayList<ExceptionEvent>();
     }
+
+
 }



Mime
View raw message