camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1073634 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/model/ camel-core/src/test/java/org/apache/camel/processor/ components/camel-spring/src/test/resources/org/apache/camel/spring/processor/
Date Wed, 23 Feb 2011 08:25:29 GMT
Author: davsclaus
Date: Wed Feb 23 08:25:28 2011
New Revision: 1073634

URL: http://svn.apache.org/viewvc?rev=1073634&view=rev
Log:
CAMEL-3707: Sort EIP does not support outputs. And in XML DSL its configured its expression
just as the other EIPs. Removed not wanted methods from Java DSL.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/SortDefinition.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SortBodyTest.java
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortBodyTest.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortExpressionTest.xml

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=1073634&r1=1073633&r2=1073634&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 Wed
Feb 23 08:25:28 2011
@@ -2547,26 +2547,13 @@ public abstract class ProcessorDefinitio
     }
 
     /**
-     * Sorts the IN message body using the given comparator.
-     * The IN body mut be convertable to {@link List}.
-     *
-     * @param comparator  the comparator to use for sorting
-     * @return the builder
-     */
-    @SuppressWarnings("unchecked")
-    public Type sortBody(Comparator comparator) {
-        addOutput(new SortDefinition(body(), comparator));
-        return (Type) this;
-    }
-
-    /**
-     * Sorts the IN message body using a default sorting based on toString representation.
-     * The IN body mut be convertable to {@link List}.
+     * Sorts the expression using a default sorting based on toString representation.
      *
+     * @param expression  the expression, must be convertable to {@link List}
      * @return the builder
      */
-    public Type sortBody() {
-        return sortBody(null);
+    public Type sort(Expression expression) {
+        return sort(expression, null);
     }
 
     /**
@@ -2583,13 +2570,14 @@ public abstract class ProcessorDefinitio
     }
 
     /**
-     * Sorts the expression using a default sorting based on toString representation. 
+     * Sorts the expression
      *
-     * @param expression  the expression, must be convertable to {@link List}
      * @return the builder
      */
-    public Type sort(Expression expression) {
-        return sort(expression, null);
+    public ExpressionClause<SortDefinition> sort() {
+        SortDefinition answer = new SortDefinition();
+        addOutput(answer);
+        return ExpressionClause.createAndSetExpression(answer);
     }
 
     /**

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/SortDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SortDefinition.java?rev=1073634&r1=1073633&r2=1073634&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/SortDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/SortDefinition.java Wed Feb
23 08:25:28 2011
@@ -16,21 +16,20 @@
  */
 package org.apache.camel.model;
 
-import java.util.Collections;
 import java.util.Comparator;
-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.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import javax.xml.bind.annotation.XmlTransient;
 
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
+import org.apache.camel.model.language.ExpressionDefinition;
 import org.apache.camel.processor.SortProcessor;
 import org.apache.camel.spi.RouteContext;
 import org.apache.camel.util.ObjectHelper;
+
 import static org.apache.camel.builder.ExpressionBuilder.bodyExpression;
 
 /**
@@ -38,19 +37,17 @@ import static org.apache.camel.builder.E
  */
 @XmlRootElement(name = "sort")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class SortDefinition extends OutputDefinition<SortDefinition> {
+public class SortDefinition extends NoOutputExpressionNode {
     @XmlTransient
     private Comparator<Object> comparator;
-    @XmlAttribute(required = false)
+    @XmlAttribute
     private String comparatorRef;
-    @XmlElement(name = "expression", required = false)
-    private ExpressionSubElementDefinition expression;
 
     public SortDefinition() {
     }
 
     public SortDefinition(Expression expression) {
-        setExpression(expression);
+        setExpression(new ExpressionDefinition(expression));
     }
 
     public SortDefinition(Expression expression, Comparator<Object> comparator) {
@@ -86,24 +83,15 @@ public class SortDefinition extends Outp
         }
 
         // if no expression provided then default to body expression
+        Expression exp;
         if (getExpression() == null) {
-            setExpression(bodyExpression());
-        }
-
-        Expression exp = expression.getExpression();
-        // fallback to the type when its been initialized from JAXB using camel-spring
-        if (exp == null) {
-            exp = expression.getExpressionType();
+            exp = bodyExpression();
+        } else {
+            exp = getExpression().createExpression(routeContext);
         }
         return new SortProcessor(exp, getComparator());
     }
 
-    @Override
-    @SuppressWarnings("unchecked")
-    public List<ProcessorDefinition> getOutputs() {
-        return Collections.EMPTY_LIST;
-    }
-
     public Comparator<Object> getComparator() {
         return comparator;
     }
@@ -120,18 +108,6 @@ public class SortDefinition extends Outp
         this.comparatorRef = comparatorRef;
     }
 
-    public ExpressionSubElementDefinition getExpression() {
-        return expression;
-    }
-
-    public void setExpression(Expression expression) {
-        this.expression = new ExpressionSubElementDefinition(expression);
-    }
-
-    public void setExpression(ExpressionSubElementDefinition expression) {
-        this.expression = expression;
-    }
-
     /**
      * Sets the comparator to use for sorting
      *

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SortBodyTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SortBodyTest.java?rev=1073634&r1=1073633&r2=1073634&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SortBodyTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SortBodyTest.java Wed
Feb 23 08:25:28 2011
@@ -43,7 +43,7 @@ public class SortBodyTest extends Contex
         return new RouteBuilder() {
             public void configure() {
                 // START SNIPPET: e1
-                from("direct:start").sortBody().to("mock:result");
+                from("direct:start").sort().body().to("mock:result");
                 // END SNIPPET: e1
             }
         };

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortBodyTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortBodyTest.xml?rev=1073634&r1=1073633&r2=1073634&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortBodyTest.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortBodyTest.xml
Wed Feb 23 08:25:28 2011
@@ -26,8 +26,10 @@
     <camelContext xmlns="http://camel.apache.org/schema/spring">
         <route>
             <from uri="direct:start"/>
-            <!-- will default sort the body using a default comparator -->
-            <sort/>
+            <!-- will sort the body using a default comparator -->
+            <sort>
+                <simple>body</simple>
+            </sort>
             <to uri="mock:result"/>
         </route>
     </camelContext>

Modified: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortExpressionTest.xml
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortExpressionTest.xml?rev=1073634&r1=1073633&r2=1073634&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortExpressionTest.xml
(original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortExpressionTest.xml
Wed Feb 23 08:25:28 2011
@@ -28,9 +28,7 @@
             <from uri="direct:start"/>
             <!-- will tokenize the body by comma and sort it -->
             <sort>
-                <expression>
-                    <tokenize token=","/>
-                </expression>
+                <tokenize token=","/>
             </sort>
             <to uri="mock:result"/>
         </route>
@@ -39,9 +37,7 @@
             <from uri="direct:reverse"/>
             <!-- will tokenize the body by comma and sort it using the comparator -->
             <sort comparatorRef="myReverseComparator">
-                <expression>
-                    <tokenize token=","/>
-                </expression>
+                <tokenize token=","/>
             </sort>
             <to uri="mock:result"/>
         </route>



Mime
View raw message