camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r771227 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/ camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/processor/ camel-core/src/main/resources/org/apache/camel/model/ camel-core/src...
Date Mon, 04 May 2009 07:51:50 GMT
Author: davsclaus
Date: Mon May  4 07:51:49 2009
New Revision: 771227

URL: http://svn.apache.org/viewvc?rev=771227&view=rev
Log:
CAMEL-1569: Added stop() support for interceptors and in routing as general.

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StopProcessor.java   (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RouteStopTest.java   (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteWhenStopTest.java
      - copied, changed from r771170, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteStopTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteStopTest.java
      - copied, changed from r771170, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteStopTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteStopTest.xml
      - copied, changed from r771170, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.xml   (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteStopTest.xml   (with props)
Removed:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProceedDefinition.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptFromDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/StopDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DefaultChannel.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Pipeline.java
    camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
    camel/trunk/camel-core/src/test/java/org/apache/camel/issues/InterceptFromLogTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/issues/InterceptFromPredicateProceedAndStopTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromRouteTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromWithPredicateAndProceedRouteTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromWithStopRouteTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteStopTest.java
    camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SInterceptFromDefinition.scala
    camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java Mon May  4 07:51:49 2009
@@ -56,6 +56,11 @@
     String LOOP_INDEX = "CamelLoopIndex";
     String LOOP_SIZE = "CamelLoopSize";
 
+    String ROUTE_STOP = "CamelRouteStop";
+
+    /**
+     * @deprecated a new Async API is planned for Camel 2.0
+     */
     String PROCESSED_SYNC = "CamelProcessedSync";
 
     String REDELIVERED = "CamelRedelivered";

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptDefinition.java?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptDefinition.java Mon May  4 07:51:49 2009
@@ -131,5 +131,4 @@
         }
     }
 
-
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptFromDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptFromDefinition.java?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptFromDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/InterceptFromDefinition.java Mon May  4 07:51:49 2009
@@ -16,17 +16,12 @@
  */
 package org.apache.camel.model;
 
-import java.util.ArrayList;
-import java.util.List;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlAttribute;
 import javax.xml.bind.annotation.XmlRootElement;
-import javax.xml.bind.annotation.XmlTransient;
 
-import org.apache.camel.Predicate;
 import org.apache.camel.Processor;
-import org.apache.camel.builder.PredicateBuilder;
 import org.apache.camel.spi.RouteContext;
 
 /**
@@ -36,22 +31,13 @@
  */
 @XmlRootElement(name = "interceptFrom")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class InterceptFromDefinition extends OutputDefinition<ProcessorDefinition> {
-
-    // TODO: we need a new interceptDefinition to uses the InterceptStrategy so its applied for each route step
-    // and a more intelligent Channel so we can stop or proceed on-the-fly
+public class InterceptFromDefinition extends InterceptDefinition {
 
     // TODO: Support lookup endpoint by ref (requires a bit more work)
     // TODO: Support wildcards for endpoints so you can match by scheme, eg jms:*
 
     @XmlAttribute(required = false)
     protected String uri;
-    @XmlTransient
-    protected ProceedDefinition proceed = new ProceedDefinition();
-    @XmlTransient
-    protected Boolean stopIntercept = Boolean.FALSE;
-    @XmlTransient
-    protected Boolean usePredicate = Boolean.FALSE;
 
     public InterceptFromDefinition() {
     }
@@ -80,147 +66,6 @@
         return createOutputsProcessor(routeContext);
     }
 
-    /**
-     * Applies this interceptor only if the given predicate is true
-     *
-     * @param predicate  the predicate
-     * @return the builder
-     */
-    public ChoiceDefinition when(Predicate predicate) {
-        usePredicate = Boolean.TRUE;
-        ChoiceDefinition choice = choice().when(PredicateBuilder.not(predicate));
-        choice.addOutput(proceed);
-        return choice.otherwise();
-    }
-
-    public ProceedDefinition getProceed() {
-        return proceed;
-    }
-
-    public void stopIntercept() {
-        setStopIntercept(Boolean.TRUE);
-    }
-
-    /**
-     * This method is <b>only</b> for handling some post configuration
-     * that is needed from the Spring DSL side as JAXB does not invoke the fluent
-     * builders, so we need to manually handle this afterwards, and since this is
-     * an interceptor it has to do a bit of magic logic to fixup to handle predicates
-     * with or without proceed/stop set as well.
-     */
-    public void afterPropertiesSet() {
-        List<ProcessorDefinition> list = new ArrayList<ProcessorDefinition>();
-        for (ProcessorDefinition out : outputs) {
-            if (out instanceof WhenDefinition) {
-                // JAXB does not invoke the when() fluent builder so we need to wrap the when in
-                // a choice with the proceed as the when for the Java DSL does
-                WhenDefinition when = (WhenDefinition) out;
-                usePredicate = Boolean.TRUE;
-                ChoiceDefinition choice = new ChoiceDefinition();
-                choice.when(PredicateBuilder.not(when.getExpression()));
-                choice.addOutput(proceed);
-                list.add(choice);
-
-                ChoiceDefinition otherwise = choice.otherwise();
-                // add the children to the otherwise
-                for (ProcessorDefinition child : when.getOutputs()) {
-                    if (child instanceof StopDefinition) {
-                        // notify we should stop
-                        stopIntercept();
-                    } else {
-                        otherwise.addOutput(child);
-                    }
-                }
-            } else if (out instanceof StopDefinition) {
-                // notify we shuld stop
-                stopIntercept();
-            } else {
-                list.add(out);
-            }
-        }
-
-        // replace old output with this redone output list
-        outputs.clear();
-        for (ProcessorDefinition out : list) {
-            addOutput(out);
-        }
-    }
-
-    // TODO: reduce complexity of this code
-
-    public InterceptFromDefinition createProxy() {
-        InterceptFromDefinition answer = new InterceptFromDefinition();
-        answer.getOutputs().addAll(this.getOutputs());
-        
-        answer.setStopIntercept(getStopIntercept());
-
-        // hack: now we need to replace the proceed of the proxy with its own
-        // a bit ugly, operating based on the assumption that the proceed is
-        // in its outputs (if proceed() was called) and/or in the
-        // outputs of the otherwise or last when clause for the predicated version.
-        if (answer.getOutputs().size() > 0) {
-            // this is for the predicate version or if a choice() is present
-            ChoiceDefinition choice = null;
-            for (ProcessorDefinition processor : answer.getOutputs()) {
-                if (processor instanceof ChoiceDefinition) {
-                    // special cases for predicates (choices)
-                    choice = (ChoiceDefinition) processor;
-
-                    // for the predicated version we add the proceed() to otherwise()
-                    // before knowing if stop() will follow, so let's make a small adjustment
-                    if (usePredicate && getStopIntercept()) {
-                        WhenDefinition when = choice.getWhenClauses().get(0);
-                        when.getOutputs().remove(this.getProceed());
-                    }
-
-                    // add proceed to the when clause
-                    addProceedProxy(this.getProceed(), answer.getProceed(),
-                        choice.getWhenClauses().get(choice.getWhenClauses().size() - 1), usePredicate && !getStopIntercept());
-
-                    // force adding a proceed at the end (otherwise) if its not a stop type
-                    addProceedProxy(this.getProceed(), answer.getProceed(), choice.getOtherwise(), !getStopIntercept());
-
-                    if (getStopIntercept()) {
-                        // must add proceed to when clause if stop is explictiy declared, otherwise when the
-                        // predicate test fails then there is no proceed
-                        // See example: InterceptFromSimpleRouteTest (City Paris is never proceeded)
-                        addProceedProxy(this.getProceed(), answer.getProceed(),
-                            choice.getWhenClauses().get(choice.getWhenClauses().size() - 1), usePredicate);
-                    }
-
-                    break;
-                }
-            }
-            if (choice == null) {
-                // force adding a proceed at the end if its not a stop type
-                addProceedProxy(this.getProceed(), answer.getProceed(), answer, !getStopIntercept());
-            }
-        }
-
-        return answer;
-    }
-
-    private void addProceedProxy(ProceedDefinition orig, ProceedDefinition proxy, ProcessorDefinition<?> processor, boolean force) {
-        int index = processor.getOutputs().indexOf(orig);
-        if (index >= 0) {
-            processor.addOutput(proxy);
-            // replace original proceed with proxy
-            List<ProcessorDefinition> outs = processor.getOutputs();
-            outs.remove(proxy);
-            outs.set(index, proxy);
-        } else if (force) {
-            processor.addOutput(proxy);
-        }
-    }
-
-    public void setStopIntercept(Boolean stop) {
-        this.stopIntercept = stop;
-    }
-
-    public Boolean getStopIntercept() {
-        return stopIntercept;
-    }
-
     public String getUri() {
         return uri;
     }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java Mon May  4 07:51:49 2009
@@ -197,8 +197,7 @@
         List<Processor> list = new ArrayList<Processor>();
         for (ProcessorDefinition output : outputs) {
             Processor processor = output.createProcessor(routeContext);
-            // if the ProceedType/StopType create processor is null we keep on going
-            if ((output instanceof ProceedDefinition || output instanceof StopDefinition || output instanceof Channel) && processor == null) {
+            if (output instanceof Channel && processor == null) {
                 continue;
             }
 
@@ -1308,7 +1307,7 @@
      * Pushes the given block on the stack as current block
      * @param block  the block
      */
-    public void pushBlock(Block block) {
+    void pushBlock(Block block) {
         blocks.add(block);
     }
 
@@ -1316,75 +1315,19 @@
      * Pops the block off the stack as current block
      * @return the block
      */
-    public Block popBlock() {
+    Block popBlock() {
         return blocks.isEmpty() ? null : blocks.removeLast();
     }
 
     /**
-     * Procceeds the given intercepted route.
-     * <p/>
-     * Proceed is used in conjunction with intercept where calling proceed will route the message through the
-     * original route path from the point of interception. This can be used to implement the
-     * <a href="http://www.enterpriseintegrationpatterns.com/Detour.html">detour</a> pattern.
-     *
-     * @return the builder
-     * @see ProcessorDefinition#proceed()
-     */
-    @SuppressWarnings("unchecked")
-    public Type proceed() {
-        ProceedDefinition proceed = null;
-        ProcessorDefinition currentProcessor = this;
-
-        if (currentProcessor instanceof InterceptFromDefinition) {
-            proceed = ((InterceptFromDefinition) currentProcessor).getProceed();
-            LOG.info("proceed() is the implied and hence not needed for an intercept()");
-        }
-        if (proceed == null) {
-            for (ProcessorDefinition node = parent; node != null; node = node.getParent()) {
-                if (node instanceof InterceptFromDefinition) {
-                    InterceptFromDefinition intercept = (InterceptFromDefinition)node;
-                    proceed = intercept.getProceed();
-                    break;
-                }
-            }
-
-            if (proceed == null) {
-                throw new IllegalArgumentException("Cannot use proceed() without being within an intercept() block");
-            }
-        }
-
-        addOutput(proceed);
-        return (Type) this;
-    }
-
-    /**
-     * Stops the given intercepted route.
-     * <p/>
-     * As opposed to {@link #proceed()} calling stop will stop the message route and <b>not</b> continue
-     * from the interepted origin.
+     * Stops continue routing the current {@link org.apache.camel.Exchange} and marks it as completed.
      *
      * @return the builder
-     * @see #proceed()
      */
     @SuppressWarnings("unchecked")
     public Type stop() {
-        ProcessorDefinition currentProcessor = this;
-
-        if (currentProcessor instanceof InterceptFromDefinition) {
-            ((InterceptFromDefinition) currentProcessor).stopIntercept();
-        } else {
-            ProcessorDefinition node;
-            for (node = parent; node != null; node = node.getParent()) {
-                if (node instanceof InterceptFromDefinition) {
-                    ((InterceptFromDefinition) node).stopIntercept();
-                    break;
-                }
-            }
-            if (node == null) {
-                throw new IllegalArgumentException("Cannot use stop() without being within an intercept() block");
-            }
-        }
-
+        StopDefinition stop = new StopDefinition();
+        addOutput(stop);
         return (Type) this;
     }
 
@@ -1396,6 +1339,7 @@
      */
     @SuppressWarnings("unchecked")
     public Type skip() {
+        // TODO: move this to InterceptSendToEndpoint so its a special builder method on it only
         ProcessorDefinition currentProcessor = this;
 
         if (currentProcessor instanceof InterceptSendToEndpointDefinition) {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/RoutesDefinition.java Mon May  4 07:51:49 2009
@@ -212,11 +212,7 @@
             }
 
             if (match) {
-                // need to create a proxy for this one and use the
-                // proceed of the proxy which will be local to this route
-                InterceptFromDefinition proxy = intercept.createProxy();
-                route.addOutput(proxy);
-                route.pushBlock(proxy.getProceed());
+                route.addOutput(intercept);
             }
         }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/StopDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/StopDefinition.java?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/StopDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/StopDefinition.java Mon May  4 07:51:49 2009
@@ -16,11 +16,14 @@
  */
 package org.apache.camel.model;
 
+import java.util.Collections;
+import java.util.List;
 import javax.xml.bind.annotation.XmlAccessType;
 import javax.xml.bind.annotation.XmlAccessorType;
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.camel.Processor;
+import org.apache.camel.processor.StopProcessor;
 import org.apache.camel.spi.RouteContext;
 
 /**
@@ -39,17 +42,23 @@
 
     @Override
     public Processor createProcessor(RouteContext routeContext) throws Exception {
-        // stop does not have any processor
-        return null;
+        return new StopProcessor();
     }
 
     @Override
     public String getLabel() {
-        return getShortName();
+        return "stop";
     }
 
     @Override
     public String toString() {
-        return getShortName();
+        return "Stop";
     }
+
+    @Override
+    @SuppressWarnings("unchecked")
+    public List<ProcessorDefinition> getOutputs() {
+        return Collections.EMPTY_LIST;
+    }
+
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DefaultChannel.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DefaultChannel.java?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DefaultChannel.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/DefaultChannel.java Mon May  4 07:51:49 2009
@@ -22,11 +22,14 @@
 import org.apache.camel.Channel;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
+import org.apache.camel.NoTypeConversionAvailableException;
 import org.apache.camel.impl.ServiceSupport;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.spi.InterceptStrategy;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.util.ServiceHelper;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
 
 /**
  * DefaultChannel is the default {@link Channel}.
@@ -42,6 +45,8 @@
  */
 public class DefaultChannel extends ServiceSupport implements Processor, Channel {
 
+    private static final transient Log LOG = LogFactory.getLog(DefaultChannel.class);
+
     private final List<InterceptStrategy> interceptors = new ArrayList<InterceptStrategy>();
     private Processor errorHandler;
     // the next processor (non wrapped)
@@ -139,11 +144,28 @@
 
     public void process(Exchange exchange) throws Exception {
         Processor processor = getOutput();
-        if (processor != null) {
+        if (processor != null && continueProcessing(exchange)) {
             processor.process(exchange);
         }
     }
 
+    /**
+     * Strategy to determine if we should continue processing the {@link Exchange}.
+     */
+    protected boolean continueProcessing(Exchange exchange) {
+        Object stop = exchange.getProperty(Exchange.ROUTE_STOP);
+        if (stop != null) {
+            boolean doStop = exchange.getContext().getTypeConverter().convertTo(Boolean.class, stop);
+            if (doStop) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Exchange is marked to stop routing: " + exchange);
+                }
+                return false;
+            }
+        }
+        return true;
+    }
+
     @Override
     public String toString() {
         // just output the next processor as all the interceptors and error handler is just too verbose

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Pipeline.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Pipeline.java?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Pipeline.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/Pipeline.java Mon May  4 07:51:49 2009
@@ -25,9 +25,11 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.Processor;
+import org.apache.camel.NoTypeConversionAvailableException;
 import org.apache.camel.impl.converter.AsyncProcessorTypeConverter;
 import org.apache.camel.util.AsyncProcessorHelper;
 import org.apache.camel.util.ExchangeHelper;
+import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
@@ -76,7 +78,9 @@
                 }
                 break;
             }
-            if (!processors.hasNext()) {
+
+            // should we continue routing or not
+            if (!continueRouting(processors, nextExchange)) {
                 break;
             }
 
@@ -123,7 +127,8 @@
 
                 // Continue processing the pipeline...
                 Exchange nextExchange = exchange;
-                while (processors.hasNext()) {
+
+                while (continueRouting(processors, nextExchange)) {
                     AsyncProcessor processor = AsyncProcessorTypeConverter.convert(processors.next());
 
                     boolean exceptionHandled = hasExceptionBeenHandled(nextExchange);
@@ -188,6 +193,23 @@
         return answer;
     }
 
+    protected boolean continueRouting(Iterator<Processor> it, Exchange exchange) {
+        Object stop = exchange.getProperty(Exchange.ROUTE_STOP);
+        if (stop != null) {
+            boolean doStop = exchange.getContext().getTypeConverter().convertTo(Boolean.class, stop);
+            if (doStop) {
+                if (LOG.isDebugEnabled()) {
+                    LOG.debug("Exchange is marked to stop routing: " + exchange);
+                }
+                return false;
+            } else {
+                return true;
+            }
+        } else {
+            return it.hasNext();
+        }
+    }
+
     @Override
     public String toString() {
         return "Pipeline" + getProcessors();

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StopProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StopProcessor.java?rev=771227&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StopProcessor.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StopProcessor.java Mon May  4 07:51:49 2009
@@ -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.processor;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+
+/**
+ * Stops continue processing the route and marks it as complete.
+ *
+ * @version $Revision$
+ */
+public class StopProcessor implements Processor {
+
+    public void process(Exchange exchange) throws Exception {
+        // mark the exchange to stop continue routing
+        exchange.setProperty(Exchange.ROUTE_STOP, Boolean.TRUE);
+    }
+
+    @Override
+    public String toString() {
+        return "StopProcessor";
+    }
+}

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

Propchange: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/StopProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index (original)
+++ camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index Mon May  4 07:51:49 2009
@@ -41,7 +41,6 @@
 OtherwiseDefinition
 PipelineDefinition
 PolicyDefinition
-ProceedDefinition
 ProcessDefinition
 RecipientListDefinition
 RedeliveryPolicyDefinition

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/issues/InterceptFromLogTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/InterceptFromLogTest.java?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/issues/InterceptFromLogTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/issues/InterceptFromLogTest.java Mon May  4 07:51:49 2009
@@ -41,8 +41,8 @@
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() throws Exception {
-                interceptFrom().to("log:foo").to("mock:foo").proceed();
-                interceptFrom().to("log:bar").to("mock:bar"); // proceed is default
+                interceptFrom().to("log:foo").to("mock:foo");
+                interceptFrom().to("log:bar").to("mock:bar");
 
                 from("seda:foo").to("seda:bar");
                 from("seda:bar").to("mock:result");

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/issues/InterceptFromPredicateProceedAndStopTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/issues/InterceptFromPredicateProceedAndStopTest.java?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/issues/InterceptFromPredicateProceedAndStopTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/issues/InterceptFromPredicateProceedAndStopTest.java Mon May  4 07:51:49 2009
@@ -48,7 +48,7 @@
     public void testInterceptorNoPredicateAndProceed() throws Exception {
         context.addRoutes(new RouteBuilder() {
             public void configure() throws Exception {
-                interceptFrom().to("mock:test").proceed();
+                interceptFrom().to("mock:test");
                 from("seda:order").to("mock:ok");
             }
         });
@@ -108,7 +108,7 @@
     public void testInterceptorWithPredicateAndProceed() throws Exception {
         context.addRoutes(new RouteBuilder() {
             public void configure() throws Exception {
-                interceptFrom().when(header("user").isEqualTo("test")).to("mock:test").proceed();
+                interceptFrom().when(header("user").isEqualTo("test")).to("mock:test");
                 from("seda:order").to("mock:ok");
             }
         });

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RouteStopTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RouteStopTest.java?rev=771227&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RouteStopTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RouteStopTest.java Mon May  4 07:51:49 2009
@@ -0,0 +1,94 @@
+/**
+ * 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.builder.RouteBuilder;
+
+/**
+ * Unit test for stop() DSL
+ *
+ * @version $Revision$
+ */
+public class RouteStopTest extends ContextTestSupport {
+
+    public void testOtherwise() throws Exception {
+        getMockEndpoint("mock:hello").expectedMessageCount(0);
+        getMockEndpoint("mock:bye").expectedMessageCount(0);
+        getMockEndpoint("mock:other").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Other");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testHello() throws Exception {
+        getMockEndpoint("mock:hello").expectedMessageCount(1);
+        getMockEndpoint("mock:bye").expectedMessageCount(0);
+        getMockEndpoint("mock:other").expectedMessageCount(0);
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testByeWithStop() throws Exception {
+        getMockEndpoint("mock:hello").expectedMessageCount(0);
+        getMockEndpoint("mock:bye").expectedMessageCount(1);
+        getMockEndpoint("mock:other").expectedMessageCount(0);
+        // we should stop so no message arrives at result
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+
+        template.sendBody("direct:start", "Bye World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testSetPropertyToStop() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedMessageCount(0);
+
+        template.sendBody("direct:foo", "Hello World");
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .choice()
+                        .when(body().contains("Hello")).to("mock:hello")
+                        .when(body().contains("Bye")).to("mock:bye").stop()
+                        .otherwise().to("mock:other")
+                    .end()
+                    .to("mock:result");
+
+
+                from("direct:foo")
+                    .to("mock:foo")
+                    .setProperty(Exchange.ROUTE_STOP, constant("true"))
+                    .to("mock:result");
+            }
+        };
+    }
+}

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

Propchange: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/RouteStopTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromRouteTest.java?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromRouteTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromRouteTest.java Mon May  4 07:51:49 2009
@@ -27,8 +27,7 @@
         return new RouteBuilder() {
             public void configure() {
                 interceptFrom().choice().
-                        when(header("foo").isEqualTo("bar")).to("mock:b").
-                        otherwise().proceed();
+                        when(header("foo").isEqualTo("bar")).to("mock:b").stop().end();
 
                 from("direct:start").to("mock:a");
             }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromWithPredicateAndProceedRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromWithPredicateAndProceedRouteTest.java?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromWithPredicateAndProceedRouteTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromWithPredicateAndProceedRouteTest.java Mon May  4 07:51:49 2009
@@ -26,7 +26,7 @@
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                interceptFrom().when(header("foo").isEqualTo("bar")).to("mock:b").proceed();
+                interceptFrom().when(header("foo").isEqualTo("bar")).to("mock:b");
 
                 from("direct:start").to("mock:a");
             }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromWithStopRouteTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromWithStopRouteTest.java?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromWithStopRouteTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptFromWithStopRouteTest.java Mon May  4 07:51:49 2009
@@ -27,7 +27,13 @@
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                interceptFrom().filter(header("foo").isEqualTo("bar")).to("mock:b").stop();
+                interceptFrom()
+                    .filter(header("foo").isEqualTo("bar"))
+                        .to("mock:b")
+                    // need end to end filter
+                    .end()
+                    // stop continue routing no matter what
+                    .stop();
 
                 from("direct:start").to("mock:a");
             }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteStopTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteStopTest.java?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteStopTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteStopTest.java Mon May  4 07:51:49 2009
@@ -25,16 +25,15 @@
 public class InterceptSimpleRouteStopTest extends ContextTestSupport {
 
     public void testInterceptWithStop() throws Exception {
-        // TODO: stop is not yet supported
-        //getMockEndpoint("mock:foo").expectedMessageCount(0);
-        //getMockEndpoint("mock:bar").expectedMessageCount(0);
-        //getMockEndpoint("mock:result").expectedMessageCount(0);
+        getMockEndpoint("mock:foo").expectedMessageCount(0);
+        getMockEndpoint("mock:bar").expectedMessageCount(0);
+        getMockEndpoint("mock:result").expectedMessageCount(0);
 
-        //getMockEndpoint("mock:intercepted").expectedMessageCount(1);
+        getMockEndpoint("mock:intercepted").expectedMessageCount(1);
 
-        //template.sendBody("direct:start", "Hello World");
+        template.sendBody("direct:start", "Hello World");
 
-        //assertMockEndpointsSatisfied();
+        assertMockEndpointsSatisfied();
     }
 
     @Override
@@ -42,11 +41,12 @@
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-//                intercept().to("mock:intercepted").stop();
-                intercept().to("mock:intercepted");
+                // START SNIPPET: e1
+                intercept().to("mock:intercepted").stop();
 
                 from("direct:start")
                     .to("mock:foo", "mock:bar", "mock:result");
+                // END SNIPPET: e1
             }
         };
     }

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteWhenStopTest.java (from r771170, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteStopTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteWhenStopTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteWhenStopTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteStopTest.java&r1=771170&r2=771227&rev=771227&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteStopTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/InterceptSimpleRouteWhenStopTest.java Mon May  4 07:51:49 2009
@@ -22,19 +22,30 @@
 /**
  * @version $Revision$
  */
-public class InterceptSimpleRouteStopTest extends ContextTestSupport {
+public class InterceptSimpleRouteWhenStopTest extends ContextTestSupport {
 
-    public void testInterceptWithStop() throws Exception {
-        // TODO: stop is not yet supported
-        //getMockEndpoint("mock:foo").expectedMessageCount(0);
-        //getMockEndpoint("mock:bar").expectedMessageCount(0);
-        //getMockEndpoint("mock:result").expectedMessageCount(0);
+    public void testInterceptStop() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(0);
+        getMockEndpoint("mock:bar").expectedMessageCount(0);
+        getMockEndpoint("mock:result").expectedMessageCount(0);
 
-        //getMockEndpoint("mock:intercepted").expectedMessageCount(1);
+        getMockEndpoint("mock:intercepted").expectedMessageCount(1);
 
-        //template.sendBody("direct:start", "Hello World");
+        template.sendBody("direct:start", "Hello World");
 
-        //assertMockEndpointsSatisfied();
+        assertMockEndpointsSatisfied();
+    }
+
+    public void testInterceptNoStop() throws Exception {
+        getMockEndpoint("mock:foo").expectedMessageCount(1);
+        getMockEndpoint("mock:bar").expectedMessageCount(1);
+        getMockEndpoint("mock:result").expectedMessageCount(1);
+
+        getMockEndpoint("mock:intercepted").expectedMessageCount(0);
+
+        template.sendBody("direct:start", "Hi");
+
+        assertMockEndpointsSatisfied();
     }
 
     @Override
@@ -42,11 +53,12 @@
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-//                intercept().to("mock:intercepted").stop();
-                intercept().to("mock:intercepted");
+                // START SNIPPET: e1
+                intercept().when(body().contains("Hello")).to("mock:intercepted").stop();
 
                 from("direct:start")
                     .to("mock:foo", "mock:bar", "mock:result");
+                // END SNIPPET: e1
             }
         };
     }

Modified: camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SInterceptFromDefinition.scala
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SInterceptFromDefinition.scala?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SInterceptFromDefinition.scala (original)
+++ camel/trunk/components/camel-scala/src/main/scala/org/apache/camel/scala/dsl/SInterceptFromDefinition.scala Mon May  4 07:51:49 2009
@@ -31,7 +31,4 @@
     this
   }
   
-  def stop =  {
-    target.setStopIntercept(true)
-  }   
 }

Modified: camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java?rev=771227&r1=771226&r2=771227&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java (original)
+++ camel/trunk/components/camel-spring/src/main/java/org/apache/camel/spring/CamelContextFactoryBean.java Mon May  4 07:51:49 2009
@@ -40,7 +40,6 @@
 import org.apache.camel.model.InterceptSendToEndpointDefinition;
 import org.apache.camel.model.OnExceptionDefinition;
 import org.apache.camel.model.PolicyDefinition;
-import org.apache.camel.model.ProceedDefinition;
 import org.apache.camel.model.ProcessorDefinition;
 import org.apache.camel.model.RouteBuilderDefinition;
 import org.apache.camel.model.RouteContainer;
@@ -59,7 +58,6 @@
 import org.apache.camel.spi.PackageScanClassResolver;
 import org.apache.camel.spi.Registry;
 import org.apache.camel.util.ObjectHelper;
-import org.apache.camel.util.ProcessorDefinitionHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.springframework.beans.factory.DisposableBean;
@@ -166,7 +164,6 @@
     }
 
     public void afterPropertiesSet() throws Exception {
-        // TODO there should be a neater way to do this!
         if (properties != null) {
             getContext().setProperties(properties.asMap());
         }
@@ -313,38 +310,9 @@
             }
 
             if (match) {
-
-                // TODO: reduce the complex of this code when we overhaul the intercept from
-
-                List<ProcessorDefinition<?>> outputs = new ArrayList<ProcessorDefinition<?>>();
-                List<ProcessorDefinition<?>> exceptionHandlers = new ArrayList<ProcessorDefinition<?>>();
-
-                for (ProcessorDefinition output : route.getOutputs()) {
-                    if (output instanceof OnExceptionDefinition) {
-                        exceptionHandlers.add(output);
-                    } else {
-                        outputs.add(output);
-                    }
-                }
-
-                // clearing the outputs
-                route.clearOutput();
-
-                // add exception handlers as top children
-                route.getOutputs().addAll(exceptionHandlers);
-
-                // add the interceptor but we must do some pre configuration beforehand
-                intercept.afterPropertiesSet();
-                InterceptFromDefinition proxy = intercept.createProxy();
-                route.addOutput(proxy);
-                route.pushBlock(proxy.getProceed());
-
-                // if there is a proceed in the interceptor proxy then we should add
-                // the current outputs to out route so we will proceed and continue to route to them
-                ProceedDefinition proceed = ProcessorDefinitionHelper.findFirstTypeInOutputs(proxy.getOutputs(), ProceedDefinition.class);
-                if (proceed != null) {
-                    proceed.getOutputs().addAll(outputs);
-                }
+                // add as first output so intercept is handled before the acutal route and that gives
+                // us the needed head start to init and be able to intercept all the remaining processing steps
+                route.getOutputs().add(0, intercept);
             }
         }
 

Copied: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteStopTest.java (from r771170, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteStopTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteStopTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteTest.java&r1=771170&r2=771227&rev=771227&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteStopTest.java Mon May  4 07:51:49 2009
@@ -18,11 +18,10 @@
 
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.processor.intercept.InterceptFromUriSimpleLogTest;
-import org.apache.camel.processor.intercept.InterceptSimpleRouteTest;
+import org.apache.camel.processor.intercept.InterceptSimpleRouteStopTest;
 import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
 
-public class SpringInterceptSimpleRouteTest extends InterceptSimpleRouteTest {
+public class SpringInterceptSimpleRouteStopTest extends InterceptSimpleRouteStopTest {
 
     @Override
     public boolean isUseRouteBuilder() {
@@ -30,7 +29,7 @@
     }
 
     protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, "org/apache/camel/spring/processor/SpringInterceptSimpleRouteTest.xml");
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/SpringInterceptSimpleRouteStopTest.xml");
     }
 
 }
\ No newline at end of file

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.java?rev=771227&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.java Mon May  4 07:51:49 2009
@@ -0,0 +1,35 @@
+/**
+ * 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.spring.processor;
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.intercept.InterceptSimpleRouteWhenStopTest;
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringInterceptSimpleRouteWhenStopTest extends InterceptSimpleRouteWhenStopTest {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.xml");
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteStopTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteStopTest.java?rev=771227&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteStopTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteStopTest.java Mon May  4 07:51:49 2009
@@ -0,0 +1,35 @@
+/**
+ * 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.spring.processor;
+
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.RouteStopTest;
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringRouteStopTest extends RouteStopTest {
+
+    @Override
+    public boolean isUseRouteBuilder() {
+        return false;
+    }
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/SpringRouteStopTest.xml");
+    }
+
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteStopTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringRouteStopTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteStopTest.xml (from r771170, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteTest.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteStopTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteStopTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteTest.xml&r1=771170&r2=771227&rev=771227&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteTest.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteStopTest.xml Mon May  4 07:51:49 2009
@@ -22,14 +22,12 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-    <!-- START SNIPPET: example -->
+    <!-- START SNIPPET: e1 -->
     <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
-        <!-- here we intercept each processing step in the routing and do a detour
-             routing where we route the exhange to the mock:intercepted endpoint.
-             Think the intercept as a AOP around that is weaven around each and
-             every route tag in the route path below -->
         <intercept>
             <to uri="mock:intercepted"/>
+            <!-- stop continue routing -->
+            <stop/>
         </intercept>
 
         <!-- here we have a very simple route -->
@@ -40,5 +38,5 @@
             <to uri="mock:result"/>
         </route>
     </camelContext>
-    <!-- END SNIPPET: example -->
+    <!-- END SNIPPET: e1 -->
 </beans>

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.xml?rev=771227&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.xml Mon May  4 07:51:49 2009
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <!-- START SNIPPET: e1 -->
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <intercept>
+            <!-- only trigger this interceptor if the message body contains the word Hello -->
+            <when>
+                <simple>${in.body} contains 'Hello'</simple>
+            </when>
+            <to uri="mock:intercepted"/>
+            <!-- stop continue routing -->
+            <stop/>
+        </intercept>
+
+        <!-- here we have a very simple route -->
+        <route>
+            <from uri="direct:start"/>
+            <to uri="mock:foo"/>
+            <to uri="mock:bar"/>
+            <to uri="mock:result"/>
+        </route>
+    </camelContext>
+    <!-- END SNIPPET: e1 -->
+</beans>

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringInterceptSimpleRouteWhenStopTest.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteStopTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteStopTest.xml?rev=771227&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteStopTest.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteStopTest.xml Mon May  4 07:51:49 2009
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+    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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="
+       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
+       http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
+    ">
+
+    <!-- START SNIPPET: example -->
+    <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="direct:start"/>
+            <choice>
+                <when><simple>${in.body} contains 'Hello'</simple>
+                    <to uri="mock:hello"/>
+                </when>
+                <when><simple>${in.body} contains 'Bye'</simple>
+                    <to uri="mock:bye"/>
+                    <!-- here we stop continue routing so this was the last processing step -->
+                    <stop/>
+                </when>
+                <otherwise>
+                    <to uri="mock:other"/>
+                </otherwise>
+            </choice>
+            <to uri="mock:result"/>
+        </route>
+    </camelContext>
+    <!-- END SNIPPET: example -->
+</beans>

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteStopTest.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteStopTest.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/SpringRouteStopTest.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message