Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 1289868D7 for ; Thu, 9 Jun 2011 13:09:13 +0000 (UTC) Received: (qmail 93828 invoked by uid 500); 9 Jun 2011 13:09:13 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 93792 invoked by uid 500); 9 Jun 2011 13:09:13 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 93785 invoked by uid 99); 9 Jun 2011 13:09:13 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jun 2011 13:09:12 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 09 Jun 2011 13:09:11 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 3716223889E1; Thu, 9 Jun 2011 13:08:51 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1133853 - in /camel/branches/camel-2.7.x: ./ camel-core/src/main/java/org/apache/camel/model/ camel-core/src/test/java/org/apache/camel/management/ camel-core/src/test/java/org/apache/camel/processor/ camel-core/src/test/java/org/apache/ca... Date: Thu, 09 Jun 2011 13:08:51 -0000 To: commits@camel.apache.org From: hadrian@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110609130851.3716223889E1@eris.apache.org> Author: hadrian Date: Thu Jun 9 13:08:50 2011 New Revision: 1133853 URL: http://svn.apache.org/viewvc?rev=1133853&view=rev Log: CAMEL-4050. Port to 2.7.x Added: camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/management/ManagedCBRTest.java - copied unchanged from r1131411, camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedCBRTest.java camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/processor/intercept/ParentChildInterceptStrategyTest.java - copied unchanged from r1131411, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/intercept/ParentChildInterceptStrategyTest.java camel/branches/camel-2.7.x/components/camel-spring/src/test/java/org/apache/camel/spring/processor/intercept/ - copied from r1131411, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/intercept/ camel/branches/camel-2.7.x/components/camel-spring/src/test/java/org/apache/camel/spring/processor/intercept/SpringParentChildInterceptStrategyTest.java - copied unchanged from r1131411, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/intercept/SpringParentChildInterceptStrategyTest.java camel/branches/camel-2.7.x/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/intercept/ - copied from r1131411, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/intercept/ camel/branches/camel-2.7.x/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/intercept/SpringParentChildInterceptStrategyTest.xml - copied unchanged from r1131411, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/intercept/SpringParentChildInterceptStrategyTest.xml Modified: camel/branches/camel-2.7.x/ (props changed) camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/model/WhenDefinition.java camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/processor/CBRWithRecipientListTest.java camel/branches/camel-2.7.x/components/camel-http/ (props changed) Propchange: camel/branches/camel-2.7.x/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Jun 9 13:08:50 2011 @@ -1 +1 @@ -/camel/trunk:1083696,1087276,1087612,1087856,1088583,1088916-1088917,1089275,1090166,1091518,1091771,1091799,1092068,1092577,1092667,1093978,1095405,1102162,1104076,1124497 +/camel/trunk:1083696,1087276,1087612,1087856,1088583,1088916-1088917,1089275,1090166,1091518,1091771,1091799,1092068,1092577,1092667,1093978,1095405,1102162,1104076,1124497,1131411 Modified: camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java?rev=1133853&r1=1133852&r2=1133853&view=diff ============================================================================== --- camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java (original) +++ camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/model/ChoiceDefinition.java Thu Jun 9 13:08:50 2011 @@ -19,7 +19,6 @@ package org.apache.camel.model; import java.util.ArrayList; 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.XmlElement; @@ -37,7 +36,7 @@ import org.apache.camel.util.CollectionS /** * Represents an XML <choice/> element * - * @version + * @version */ @XmlRootElement(name = "choice") @XmlAccessorType(XmlAccessType.FIELD) @@ -59,11 +58,12 @@ public class ChoiceDefinition extends Pr } } + @Override public String getShortName() { return "choice"; } - + @Override public Processor createProcessor(RouteContext routeContext) throws Exception { List filters = new ArrayList(); @@ -79,10 +79,11 @@ public class ChoiceDefinition extends Pr // Fluent API // ------------------------------------------------------------------------- + /** * Sets the predicate for the when node * - * @param predicate the predicate + * @param predicate the predicate * @return the builder */ public ChoiceDefinition when(Predicate predicate) { @@ -108,7 +109,7 @@ public class ChoiceDefinition extends Pr /** * Sets the otherwise node - * + * * @return the builder */ public ChoiceDefinition otherwise() { @@ -118,6 +119,33 @@ public class ChoiceDefinition extends Pr return this; } + @Override + public void setId(String value) { + // when setting id, we should set it on the fine grained element, if possible + if (otherwise != null) { + otherwise.setId(value); + } else if (!getWhenClauses().isEmpty()) { + int size = getWhenClauses().size(); + getWhenClauses().get(size - 1).setId(value); + } else { + super.setId(value); + } + } + + @Override + public void addOutput(ProcessorDefinition output) { + super.addOutput(output); + // re-configure parent as its a tad more complex for the CNR + if (otherwise != null) { + output.setParent(otherwise); + } else if (!getWhenClauses().isEmpty()) { + int size = getWhenClauses().size(); + output.setParent(getWhenClauses().get(size - 1)); + } else { + output.setParent(this); + } + } + // Properties // ------------------------------------------------------------------------- Modified: camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java?rev=1133853&r1=1133852&r2=1133853&view=diff ============================================================================== --- camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java (original) +++ camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java Thu Jun 9 13:08:50 2011 @@ -1107,11 +1107,24 @@ public abstract class ProcessorDefinitio if (blocks.isEmpty()) { if (parent == null) { - return this; + return this.endParent(); } - return parent; + return parent.endParent(); } popBlock(); + return this.endParent(); + } + + /** + * Strategy to allow {@link ProcessorDefinition}s to have special logic when using end() in the DSL + * to return back to the intended parent. + *

+ * For example a content based router we return back to the {@link ChoiceDefinition} when we end() + * from a {@link WhenDefinition}. + * + * @return the end + */ + public ProcessorDefinition endParent() { return this; } @@ -1121,7 +1134,14 @@ public abstract class ProcessorDefinitio * @return the builder */ public ChoiceDefinition endChoice() { - return (ChoiceDefinition) end(); + ProcessorDefinition def = end(); + if (def instanceof WhenDefinition) { + return (ChoiceDefinition) def.getParent(); + } else if (def instanceof OtherwiseDefinition) { + return (ChoiceDefinition) def.getParent(); + } else { + return (ChoiceDefinition) def; + } } /** Modified: camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/model/WhenDefinition.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/model/WhenDefinition.java?rev=1133853&r1=1133852&r2=1133853&view=diff ============================================================================== --- camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/model/WhenDefinition.java (original) +++ camel/branches/camel-2.7.x/camel-core/src/main/java/org/apache/camel/model/WhenDefinition.java Thu Jun 9 13:08:50 2011 @@ -68,7 +68,13 @@ public class WhenDefinition extends Expr public FilterProcessor createProcessor(RouteContext routeContext) throws Exception { return createFilterProcessor(routeContext); } - + + @Override + public ProcessorDefinition endParent() { + // when using when in the DSL we don't want to end back to this when, but instead + // the parent of this, so return the parent + return this.getParent(); + } // Fluent API //------------------------------------------------------------------------- /** Modified: camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/processor/CBRWithRecipientListTest.java URL: http://svn.apache.org/viewvc/camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/processor/CBRWithRecipientListTest.java?rev=1133853&r1=1133852&r2=1133853&view=diff ============================================================================== --- camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/processor/CBRWithRecipientListTest.java (original) +++ camel/branches/camel-2.7.x/camel-core/src/test/java/org/apache/camel/processor/CBRWithRecipientListTest.java Thu Jun 9 13:08:50 2011 @@ -64,7 +64,8 @@ public class CBRWithRecipientListTest ex .when(body().contains("Camel")) .recipientList(header("foo")).end() .when(body().contains("Donkey")) - .recipientList(header("bar")).end() + // we can do either end() or endChoice() + .recipientList(header("bar")).endChoice() .otherwise() .to("mock:result"); } Propchange: camel/branches/camel-2.7.x/components/camel-http/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Thu Jun 9 13:08:50 2011 @@ -1 +1 @@ -/camel/trunk/components/camel-http:917526,1083696,1087276,1087612,1087856,1088583,1088916-1088917,1089275,1090166,1091518,1091771,1091799,1092068,1092577,1092667,1093978,1095405,1102162,1104076,1124497 +/camel/trunk/components/camel-http:917526,1083696,1087276,1087612,1087856,1088583,1088916-1088917,1089275,1090166,1091518,1091771,1091799,1092068,1092577,1092667,1093978,1095405,1102162,1104076,1124497,1131411