Author: jstrachan
Date: Thu Jun 19 11:58:33 2008
New Revision: 669650

URL: http://svn.apache.org/viewvc?rev=669650&view=rev
Log:
first spike at implementing https://issues.apache.org/activemq/browse/CAMEL-619

Added:
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchangeFormatter.java
   (with props)
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/ExchangeFormatter.java
   (with props)
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java
   (with props)
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
      - copied, changed from r669175, 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DebugInterceptor.java
    
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceInterceptorTest.java
   (with props)
Modified:
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Logger.java
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/Debugger.java
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/UnitOfWork.java

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java?rev=669650&r1=669649&r2=669650&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/CamelContext.java
 Thu Jun 19 11:58:33 2008
@@ -21,11 +21,7 @@
 import java.util.concurrent.Callable;
 
 import org.apache.camel.model.RouteType;
-import org.apache.camel.spi.ExchangeConverter;
-import org.apache.camel.spi.Injector;
-import org.apache.camel.spi.Language;
-import org.apache.camel.spi.LifecycleStrategy;
-import org.apache.camel.spi.Registry;
+import org.apache.camel.spi.*;
 
 /**
  * Interface used to represent the context used to configure routes and the
@@ -201,4 +197,5 @@
      */
     <E extends Exchange> ProducerTemplate<E> createProducerTemplate();
 
+    void addInterceptStrategy(InterceptStrategy interceptStrategy);
 }

Added: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchangeFormatter.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchangeFormatter.java?rev=669650&view=auto
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchangeFormatter.java
 (added)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchangeFormatter.java
 Thu Jun 19 11:58:33 2008
@@ -0,0 +1,38 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.impl;
+
+import org.apache.camel.processor.interceptor.ExchangeFormatter;
+import org.apache.camel.Exchange;
+
+/**
+ * A default [EMAIL PROTECTED] ExchangeFormatter} which just uses the [EMAIL 
PROTECTED] org.apache.camel.Exchange#toString()} method
+ *  
+ * @version $Revision: 1.1 $
+ */
+public class DefaultExchangeFormatter implements ExchangeFormatter {
+    protected static final DefaultExchangeFormatter instance = new 
DefaultExchangeFormatter();
+
+    public static DefaultExchangeFormatter getInstance() {
+        return instance;
+    }
+
+    public Object format(Exchange exchange) {
+        return exchange;
+    }
+}

Propchange: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchangeFormatter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java?rev=669650&r1=669649&r2=669650&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultUnitOfWork.java
 Thu Jun 19 11:58:33 2008
@@ -16,14 +16,15 @@
  */
 package org.apache.camel.impl;
 
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CountDownLatch;
-
 import org.apache.camel.AsyncCallback;
 import org.apache.camel.Exchange;
 import org.apache.camel.spi.Synchronization;
 import org.apache.camel.spi.UnitOfWork;
+import org.apache.camel.util.UuidGenerator;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
 
 /**
  * The default implementation of [EMAIL PROTECTED] UnitOfWork}
@@ -31,6 +32,9 @@
  * @version $Revision$
  */
 public class DefaultUnitOfWork implements UnitOfWork {
+    private static final UuidGenerator DEFAULT_ID_GENERATOR = new 
UuidGenerator();
+
+    private String id;
     private List<Synchronization> synchronizations;
     private List<AsyncCallback> asyncCallbacks;
     private CountDownLatch latch;
@@ -72,6 +76,18 @@
     }
 
     /**
+     * Returns the unique ID of this unit of work, lazily creating one if it 
does not yet have one
+     *
+     * @return
+     */
+    public String getId() {
+        if (id == null) {
+            id = DEFAULT_ID_GENERATOR.generateId();
+        }
+        return id;
+    }
+
+    /**
      * Register some asynchronous processing step
      */
     /*

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Logger.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Logger.java?rev=669650&r1=669649&r2=669650&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Logger.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Logger.java
 Thu Jun 19 11:58:33 2008
@@ -18,6 +18,9 @@
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
+import org.apache.camel.impl.DefaultExchangeFormatter;
+import org.apache.camel.processor.interceptor.ExchangeFormatter;
+import org.apache.camel.processor.interceptor.TraceInterceptor;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -30,6 +33,7 @@
 public class Logger implements Processor {
     private Log log;
     private LoggingLevel level;
+    private ExchangeFormatter formatter = 
DefaultExchangeFormatter.getInstance();
 
     public Logger() {
         this(LogFactory.getLog(Logger.class));
@@ -52,6 +56,11 @@
         this(LogFactory.getLog(logName), level);
     }
 
+    public Logger(Log log,ExchangeFormatter formatter) {
+        this(log);
+        this.formatter = formatter;
+    }
+
     @Override
     public String toString() {
         return "Logger[" + log + "]";
@@ -94,6 +103,43 @@
         }
     }
 
+    public void process(Exchange exchange, Throwable exception) {
+        switch (level) {
+        case DEBUG:
+            if (log.isDebugEnabled()) {
+                log.debug(logMessage(exchange), exception);
+            }
+            break;
+        case ERROR:
+            if (log.isErrorEnabled()) {
+                log.error(logMessage(exchange), exception);
+            }
+            break;
+        case FATAL:
+            if (log.isFatalEnabled()) {
+                log.fatal(logMessage(exchange), exception);
+            }
+            break;
+        case INFO:
+            if (log.isInfoEnabled()) {
+                log.info(logMessage(exchange), exception);
+            }
+            break;
+        case TRACE:
+            if (log.isTraceEnabled()) {
+                log.trace(logMessage(exchange), exception);
+            }
+            break;
+        case WARN:
+            if (log.isWarnEnabled()) {
+                log.warn(logMessage(exchange), exception);
+            }
+            break;
+        default:
+            log.error("Unknown level: " + level + " when trying to log 
exchange: " + logMessage(exchange));
+        }
+    }
+
     public void log(String message) {
         switch (level) {
         case DEBUG:
@@ -169,7 +215,7 @@
     }
 
     protected Object logMessage(Exchange exchange) {
-        return exchange;
+        return formatter.format(exchange);
     }
 
     public Log getLog() {

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=669650&r1=669649&r2=669650&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
 Thu Jun 19 11:58:33 2008
@@ -40,6 +40,9 @@
 
     private int exchangeBufferSize = -1;
     private Map<String, DebugInterceptor> interceptors = new HashMap<String, 
DebugInterceptor>();
+    private boolean logExchanges = true;
+    private TraceFormatter formatter = new TraceFormatter();
+
 
     /**
      * A helper method to return the debugger instance for a given [EMAIL 
PROTECTED] CamelContext} if one is enabled
@@ -91,6 +94,9 @@
 
     public Processor wrapProcessorInInterceptors(ProcessorType processorType, 
Processor target) throws Exception {
         String id = processorType.idOrCreate();
+        if (logExchanges) {
+            target = new TraceInterceptor(processorType, target, formatter);
+        }
         DebugInterceptor interceptor = new DebugInterceptor(processorType, 
target, createExchangeList(), createExceptionsList());
         interceptors.put(id, interceptor);
         if (LOG.isDebugEnabled()) {

Added: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/ExchangeFormatter.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/ExchangeFormatter.java?rev=669650&view=auto
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/ExchangeFormatter.java
 (added)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/ExchangeFormatter.java
 Thu Jun 19 11:58:33 2008
@@ -0,0 +1,33 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor.interceptor;
+
+import org.apache.camel.Exchange;
+
+/**
+ * A plugin used to turn an [EMAIL PROTECTED] Exchange} into a String
+ * so it can be logged to a file
+ *
+ * @version $Revision: 1.1 $
+ */
+public interface ExchangeFormatter {
+    /**
+     * Generates a string representation of the exchange
+     */
+    Object format(Exchange exchange);
+}

Propchange: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/ExchangeFormatter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java?rev=669650&view=auto
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java
 (added)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java
 Thu Jun 19 11:58:33 2008
@@ -0,0 +1,107 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor.interceptor;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.spi.UnitOfWork;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class TraceFormatter {
+    private boolean showProperties = true;
+    private boolean showHeaders = true;
+    private boolean showBody = true;
+    private boolean showExchangeId = false;
+    private boolean showBreadCrumb = false;
+
+    public Object format(TraceInterceptor interceptor, Exchange exchange) {
+        Message in = exchange.getIn();
+        Throwable exception = exchange.getException();
+        return (showBreadCrumb ? getBreadCrumbID(exchange) + " " : "")
+                + "-> " + getNodeMessage(interceptor) + " "
+                + exchange.getPattern()
+                + (showExchangeId ? " Id: " + exchange.getExchangeId() : "")
+                + ((showProperties) ? " Properties:" + 
exchange.getProperties() : "")
+                + ((showHeaders) ? " Headers:" + in.getHeaders() : "")
+                + ((showBody) ? " Body:" + getBodyAsString(in) : "")
+                + (exception != null ? " Exception: " + exception : "");
+    }
+
+
+    public boolean isShowBody() {
+        return showBody;
+    }
+
+    public void setShowBody(boolean showBody) {
+        this.showBody = showBody;
+    }
+
+    public boolean isShowBreadCrumb() {
+        return showBreadCrumb;
+    }
+
+    public void setShowBreadCrumb(boolean showBreadCrumb) {
+        this.showBreadCrumb = showBreadCrumb;
+    }
+
+    public boolean isShowExchangeId() {
+        return showExchangeId;
+    }
+
+    public void setShowExchangeId(boolean showExchangeId) {
+        this.showExchangeId = showExchangeId;
+    }
+
+    public boolean isShowHeaders() {
+        return showHeaders;
+    }
+
+    public void setShowHeaders(boolean showHeaders) {
+        this.showHeaders = showHeaders;
+    }
+
+    public boolean isShowProperties() {
+        return showProperties;
+    }
+
+    public void setShowProperties(boolean showProperties) {
+        this.showProperties = showProperties;
+    }
+
+    // Implementation methods
+    //-------------------------------------------------------------------------
+    protected Object getBreadCrumbID(Exchange exchange) {
+        UnitOfWork unitOfWork = exchange.getUnitOfWork();
+        return unitOfWork.getId();
+    }
+
+    protected Object getBodyAsString(Message in) {
+        Object answer = in.getBody(String.class);
+        if (answer == null) {
+            answer = in.getBody();
+        }
+        return answer;
+    }
+
+
+    protected String getNodeMessage(TraceInterceptor interceptor) {
+        return interceptor.getNode().getId();
+    }
+}

Propchange: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceFormatter.java
------------------------------------------------------------------------------
    svn:eol-style = native

Copied: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java
 (from r669175, 
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/TraceInterceptor.java?p2=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/TraceInterceptor.java&p1=activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/interceptor/DebugInterceptor.java&r1=669175&r2=669650&rev=669650&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/TraceInterceptor.java
 Thu Jun 19 11:58:33 2008
@@ -16,68 +16,62 @@
  */
 package org.apache.camel.processor.interceptor;
 
-import java.util.List;
-
 import org.apache.camel.Exchange;
-import org.apache.camel.Message;
 import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
 import org.apache.camel.model.ProcessorType;
 import org.apache.camel.processor.DelegateProcessor;
+import org.apache.camel.processor.Logger;
+import org.apache.camel.processor.LoggingLevel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * An interceptor for debugging and tracing routes
  *
  * @version $Revision$
  */
-public class DebugInterceptor extends DelegateProcessor {
+public class TraceInterceptor extends DelegateProcessor implements 
ExchangeFormatter {
     private final ProcessorType node;
-    private final List<Exchange> exchanges;
-    private final List<ExceptionEvent> exceptions;
     private Predicate traceFilter;
-    private Breakpoint breakpoint = new Breakpoint();
     private boolean traceExceptions = true;
+    private Logger logger = new 
Logger(LogFactory.getLog(TraceInterceptor.class), this);
+    private TraceFormatter formatter;
 
-    public DebugInterceptor(ProcessorType node, Processor target, 
List<Exchange> exchanges, List<ExceptionEvent> exceptions) {
+    public TraceInterceptor(ProcessorType node, Processor target, 
TraceFormatter formatter) {
         super(target);
         this.node = node;
-        this.exchanges = exchanges;
-        this.exceptions = exceptions;
+        this.formatter = formatter;
     }
 
     @Override
     public String toString() {
-        return "DebugInterceptor[" + node + "]";
+        return "TraceInterceptor[" + node + "]";
     }
 
     public void process(Exchange exchange) throws Exception {
-        checkForBreakpoint(exchange);
-        addTraceExchange(exchange);
         try {
+            if (shouldLogExchange(exchange)) {
+                logExchange(exchange);
+            }
             super.proceed(exchange);
         } catch (Exception e) {
-            onException(exchange, e);
+            logException(exchange, e);
             throw e;
         } catch (Error e) {
-            onException(exchange, e);
+            logException(exchange, e);
             throw e;
         }
     }
 
-    public ProcessorType getNode() {
-        return node;
-    }
-
-    public List<Exchange> getExchanges() {
-        return exchanges;
-    }
-
-    public List<ExceptionEvent> getExceptions() {
-        return exceptions;
+    public Object format(Exchange exchange) {
+        return formatter.format(this, exchange);
     }
 
-    public Breakpoint getBreakpoint() {
-        return breakpoint;
+    // Properties
+    //-------------------------------------------------------------------------
+    public ProcessorType getNode() {
+        return node;
     }
 
     public Predicate getTraceFilter() {
@@ -96,53 +90,50 @@
         this.traceExceptions = traceExceptions;
     }
 
-    /**
-     * Stategy method to wait for a breakpoint if one is set
-     */
-    protected void checkForBreakpoint(Exchange exchange) {
-        breakpoint.waitForBreakpoint(exchange);
+    public Logger getLogger() {
+        return logger;
     }
 
-    /**
-     * Fired when an exception is thrown when processing the underlying 
processor
-     */
-    protected void onException(Exchange exchange, Throwable e) {
-        if (shouldTraceExceptionEvents(exchange, e))  {
-            exceptions.add(new ExceptionEvent(this, exchange, e));
-        }
+    public TraceFormatter getFormatter() {
+        return formatter;
+    }
 
+    public void setFormatter(TraceFormatter formatter) {
+        this.formatter = formatter;
     }
 
-    private boolean shouldTraceExceptionEvents(Exchange exchange, Throwable e) 
{
-        return isTraceExceptions();
+    public LoggingLevel getLevel() {
+        return getLogger().getLevel();
     }
 
-    /**
-     * Strategy method to store the exchange in a trace log if it is enabled
-     */
-    protected void addTraceExchange(Exchange exchange) {
-        if (shouldTraceExchange(exchange)) {
-            exchanges.add(copyExchange(exchange));
-        }
+    public Log getLog() {
+        return getLogger().getLog();
     }
 
-    protected Exchange copyExchange(Exchange previousExchange) {
-        Exchange answer = previousExchange.newInstance();
-        answer.getProperties().putAll(previousExchange.getProperties());
-        answer.getIn().copyFrom(previousExchange.getIn());
-
-        // only copy the out if its defined
-        Message previousOut = previousExchange.getOut(false);
-        if (previousOut != null) {
-            answer.getOut().copyFrom(previousOut);
-        }
-        return answer;
+    public void setLog(Log log) {
+        getLogger().setLog(log);
+    }
+
+    public void setLevel(LoggingLevel level) {
+        getLogger().setLevel(level);
     }
 
+    // Implementation methods
+    //-------------------------------------------------------------------------
+    protected void logExchange(Exchange exchange) {
+        logger.process(exchange);
+    }
+
+    protected void logException(Exchange exchange, Throwable throwable) {
+        logger.process(exchange, throwable);
+    }
+
+
     /**
      * Returns true if the given exchange should be logged in the trace list
      */
-    protected boolean shouldTraceExchange(Exchange exchange) {
+    protected boolean shouldLogExchange(Exchange exchange) {
         return traceFilter == null || traceFilter.matches(exchange);
     }
-}
+
+}
\ No newline at end of file

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/UnitOfWork.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/UnitOfWork.java?rev=669650&r1=669649&r2=669650&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/UnitOfWork.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/UnitOfWork.java
 Thu Jun 19 11:58:33 2008
@@ -45,4 +45,11 @@
      * Invoked when this unit of work has been completed, whether it has 
failed or completed
      */
     void done(Exchange exchange);
+
+    /**
+     * Returns the unique ID of this unit of work, lazily creating one if it 
does not yet have one
+     *
+     * @return
+     */
+    String getId();
 }

Added: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceInterceptorTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceInterceptorTest.java?rev=669650&view=auto
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceInterceptorTest.java
 (added)
+++ 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceInterceptorTest.java
 Thu Jun 19 11:58:33 2008
@@ -0,0 +1,54 @@
+/**
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.processor.interceptor.Debugger;
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version $Revision: 1.1 $
+ */
+public class TraceInterceptorTest extends ContextTestSupport {
+    public void testSendingSomeMessages() throws Exception {
+        template.sendBodyAndHeader("direct:start", "body1", "header1", 
"value1");
+        template.sendBodyAndHeader("direct:start", "body2", "header1", 
"value2");
+    }
+
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() throws Exception {
+                // lets add the debugger which traces by default
+                getContext().addInterceptStrategy(new Debugger());
+
+                from("direct:start").
+                        process(new Processor() {
+                            public void process(Exchange exchange) throws 
Exception {
+                                // do nothing
+
+                            }
+                        }).
+                        to("mock:a").
+                        to("mock:b");
+            }
+        };
+    }
+}

Propchange: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/TraceInterceptorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to