camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r746225 - in /camel/trunk: camel-core/src/main/java/org/apache/camel/builder/ camel-core/src/main/java/org/apache/camel/language/simple/ camel-core/src/main/java/org/apache/camel/model/ camel-core/src/main/java/org/apache/camel/model/langua...
Date Fri, 20 Feb 2009 12:54:51 GMT
Author: davsclaus
Date: Fri Feb 20 12:54:50 2009
New Revision: 746225

URL: http://svn.apache.org/viewvc?rev=746225&view=rev
Log:
CAMEL-1363: Introduced sort DSL. Polished code a bit.

Added:
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/SortType.java   (contents, props changed)
      - copied, changed from r746146, camel/trunk/camel-core/src/main/java/org/apache/camel/model/ConvertBodyType.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SortProcessor.java   (with props)
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SortBodyTest.java
      - copied, changed from r746146, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SortExpressionTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSortBodyTest.java
      - copied, changed from r746146, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetBodyTest.java
    camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSortExpressionTest.java   (with props)
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortBodyTest.xml
      - copied, changed from r746146, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setBody.xml
    camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortExpressionTest.xml   (with props)
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/Builder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguageSupport.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/TokenizerExpression.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/view/GraphGeneratorSupport.java
    camel/trunk/camel-core/src/main/resources/org/apache/camel/model/jaxb.index
    camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ExpressionBuilderTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/Builder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/Builder.java?rev=746225&r1=746224&r2=746225&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/Builder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/Builder.java Fri Feb 20 12:54:50 2009
@@ -148,7 +148,7 @@
      * Returns an expression for the given system property
      */
     public static ValueBuilder systemProperty(final String name, final String defaultValue) {
-        return new ValueBuilder(ExpressionBuilder.systemProperty(name, defaultValue));
+        return new ValueBuilder(ExpressionBuilder.systemPropertyExpression(name, defaultValue));
     }
 
     /**

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java?rev=746225&r1=746224&r2=746225&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ExpressionBuilder.java Fri Feb 20 12:54:50 2009
@@ -22,7 +22,10 @@
 import java.nio.channels.ReadableByteChannel;
 import java.text.SimpleDateFormat;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.Date;
+import java.util.List;
 import java.util.Scanner;
 import java.util.regex.Pattern;
 
@@ -238,6 +241,7 @@
      * Returns an expression for a system property value with the given name
      *
      * @param propertyName the name of the system property the expression will return
+     * @param defaultValue default value to return if no system property exists
      * @return an expression object which will return the system property value
      */
     public static Expression systemPropertyExpression(final String propertyName,
@@ -290,34 +294,34 @@
     }
 
     /**
-     * Returns the expression for the exchanges inbound message body type
+     * Returns the expression for the exchanges inbound message body converted
+     * to the given type
      */
-    public static Expression bodyType() {
+    public static <T> Expression bodyExpression(final Class<T> type) {
         return new ExpressionAdapter() {
             public Object evaluate(Exchange exchange) {
-                return exchange.getIn().getBody().getClass();
+                return exchange.getIn().getBody(type);
             }
 
             @Override
             public String toString() {
-                return "bodyType";
+                return "bodyAs[" + type.getName() + "]";
             }
         };
     }
 
     /**
-     * Returns the expression for the exchanges inbound message body converted
-     * to the given type
+     * Returns the expression for the exchanges inbound message body type
      */
-    public static <T> Expression bodyExpression(final Class<T> type) {
+    public static Expression bodyTypeExpression() {
         return new ExpressionAdapter() {
             public Object evaluate(Exchange exchange) {
-                return exchange.getIn().getBody(type);
+                return exchange.getIn().getBody().getClass();
             }
 
             @Override
             public String toString() {
-                return "bodyAs[" + type.getName() + "]";
+                return "bodyType";
             }
         };
     }
@@ -447,7 +451,7 @@
     /**
      * Returns an expression which converts the given expression to the given type
      */
-    public static Expression convertTo(final Expression expression, final Class type) {
+    public static Expression convertToExpression(final Expression expression, final Class type) {
         return new ExpressionAdapter() {
             public Object evaluate(Exchange exchange) {
                 return expression.evaluate(exchange, type);
@@ -464,7 +468,7 @@
      * Returns an expression which converts the given expression to the given type the type
      * expression is evaluted to
      */
-    public static Expression convertTo(final Expression expression, final Expression type) {
+    public static Expression convertToExpression(final Expression expression, final Expression type) {
         return new ExpressionAdapter() {
             public Object evaluate(Exchange exchange) {
                 return expression.evaluate(exchange, type.evaluate(exchange).getClass());
@@ -502,8 +506,8 @@
      * Returns a tokenize expression which will tokenize the string with the
      * given regex
      */
-    public static Expression regexTokenize(final Expression expression,
-                                           final String regexTokenizer) {
+    public static Expression regexTokenizeExpression(final Expression expression,
+                                                     final String regexTokenizer) {
         final Pattern pattern = Pattern.compile(regexTokenizer);
         return new ExpressionAdapter() {
             public Object evaluate(Exchange exchange) {
@@ -520,40 +524,25 @@
         };
     }
 
-    private static Scanner getScanner(Exchange exchange, Object value) {
-        String charset = exchange.getProperty(Exchange.CHARSET_NAME, String.class);
-
-        Scanner scanner = null;
-        if (value instanceof Readable) {
-            scanner = new Scanner((Readable)value);
-        } else if (value instanceof InputStream) {
-            scanner = charset == null ? new Scanner((InputStream)value)
-                : new Scanner((InputStream)value, charset);
-        } else if (value instanceof File) {
-            try {
-                scanner = charset == null ? new Scanner((File)value) : new Scanner((File)value, charset);
-            } catch (FileNotFoundException e) {
-                throw new RuntimeCamelException(e);
+    /**
+     * Returns a sort expression which will sort the expression with the given comparator.
+     * <p/>
+     * The expression is evaluted as a {@link List} object to allow sorting.
+     */
+    @SuppressWarnings("unchecked")
+    public static Expression sortExpression(final Expression expression, final Comparator comparator) {
+        return new ExpressionAdapter() {
+            public Object evaluate(Exchange exchange) {
+                List list = expression.evaluate(exchange, List.class);
+                Collections.sort(list, comparator);
+                return list;
             }
-        } else if (value instanceof String) {
-            scanner = new Scanner((String)value);
-        } else if (value instanceof ReadableByteChannel) {
-            scanner = charset == null ? new Scanner((ReadableByteChannel)value)
-                : new Scanner((ReadableByteChannel)value, charset);
-        }
 
-        if (scanner == null) {
-            // value is not a suitable type, try to convert value to a string
-            String text = exchange.getContext().getTypeConverter().convertTo(String.class, exchange, value);
-            if (text != null) {
-                scanner = new Scanner(text);
+            @Override
+            public String toString() {
+                return "sort(" + expression + " by: " + comparator + ")";
             }
-        }
-        
-        if (scanner == null) {
-            scanner = new Scanner("");
-        }
-        return scanner;
+        };
     }
 
     /**
@@ -565,7 +554,7 @@
         final Pattern pattern = Pattern.compile(regex);
         return new ExpressionAdapter() {
             public Object evaluate(Exchange exchange) {
-                String text = evaluateStringExpression(expression, exchange);
+                String text = expression.evaluate(exchange, String.class);
                 if (text == null) {
                     return null;
                 }
@@ -589,8 +578,8 @@
         final Pattern pattern = Pattern.compile(regex);
         return new ExpressionAdapter() {
             public Object evaluate(Exchange exchange) {
-                String text = evaluateStringExpression(expression, exchange);
-                String replacement = evaluateStringExpression(replacementExpression, exchange);
+                String text = expression.evaluate(exchange, String.class);
+                String replacement = replacementExpression.evaluate(exchange, String.class);
                 if (text == null || replacement == null) {
                     return null;
                 }
@@ -610,7 +599,7 @@
     public static Expression append(final Expression left, final Expression right) {
         return new ExpressionAdapter() {
             public Object evaluate(Exchange exchange) {
-                return evaluateStringExpression(left, exchange) + evaluateStringExpression(right, exchange);
+                return left.evaluate(exchange, String.class) + right.evaluate(exchange, String.class);
             }
 
             @Override
@@ -621,37 +610,6 @@
     }
 
     /**
-     * Evaluates the expression on the given exchange and returns the String
-     * representation
-     *
-     * @param expression the expression to evaluate
-     * @param exchange the exchange to use to evaluate the expression
-     * @return the String representation of the expression or null if it could
-     *         not be evaluated
-     */
-    public static String evaluateStringExpression(Expression expression, Exchange exchange) {
-        return expression.evaluate(exchange, String.class);
-    }
-
-    /**
-     * Returns an expression for the given system property
-     */
-    public static Expression systemProperty(final String name) {
-        return systemProperty(name, null);
-    }
-
-    /**
-     * Returns an expression for the given system property
-     */
-    public static Expression systemProperty(final String name, final String defaultValue) {
-        return new ExpressionAdapter() {
-            public Object evaluate(Exchange exchange) {
-                return System.getProperty(name, defaultValue);
-            }
-        };
-    }
-
-    /**
      * Returns an expression which returns the string concatenation value of the various
      * expressions
      *
@@ -675,7 +633,7 @@
             public Object evaluate(Exchange exchange) {
                 StringBuffer buffer = new StringBuffer();
                 for (Expression expression : expressions) {
-                    String text = evaluateStringExpression(expression, exchange);
+                    String text = expression.evaluate(exchange, String.class);
                     if (text != null) {
                         buffer.append(text);
                     }
@@ -778,4 +736,40 @@
         return beanExpression(expression);
     }
 
+    private static Scanner getScanner(Exchange exchange, Object value) {
+        String charset = exchange.getProperty(Exchange.CHARSET_NAME, String.class);
+
+        Scanner scanner = null;
+        if (value instanceof Readable) {
+            scanner = new Scanner((Readable)value);
+        } else if (value instanceof InputStream) {
+            scanner = charset == null ? new Scanner((InputStream)value)
+                    : new Scanner((InputStream)value, charset);
+        } else if (value instanceof File) {
+            try {
+                scanner = charset == null ? new Scanner((File)value) : new Scanner((File)value, charset);
+            } catch (FileNotFoundException e) {
+                throw new RuntimeCamelException(e);
+            }
+        } else if (value instanceof String) {
+            scanner = new Scanner((String)value);
+        } else if (value instanceof ReadableByteChannel) {
+            scanner = charset == null ? new Scanner((ReadableByteChannel)value)
+                    : new Scanner((ReadableByteChannel)value, charset);
+        }
+
+        if (scanner == null) {
+            // value is not a suitable type, try to convert value to a string
+            String text = exchange.getContext().getTypeConverter().convertTo(String.class, exchange, value);
+            if (text != null) {
+                scanner = new Scanner(text);
+            }
+        }
+
+        if (scanner == null) {
+            scanner = new Scanner("");
+        }
+        return scanner;
+    }
+
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java?rev=746225&r1=746224&r2=746225&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/builder/ValueBuilder.java Fri Feb 20 12:54:50 2009
@@ -17,6 +17,7 @@
 package org.apache.camel.builder;
 
 import java.util.ArrayList;
+import java.util.Comparator;
 import java.util.List;
 
 import org.apache.camel.Exchange;
@@ -106,7 +107,7 @@
         List<Predicate> predicates = new ArrayList<Predicate>();
         for (Object value : values) {
             Expression right = asExpression(value);
-            right = ExpressionBuilder.convertTo(right, expression);
+            right = ExpressionBuilder.convertToExpression(right, expression);
             Predicate predicate = onNewPredicate(PredicateBuilder.isEqualTo(expression, right));
             predicates.add(predicate);
         }
@@ -160,7 +161,7 @@
      * regular expression
      */
     public ValueBuilder regexTokenize(String regex) {
-        Expression newExp = ExpressionBuilder.regexTokenize(expression, regex);
+        Expression newExp = ExpressionBuilder.regexTokenizeExpression(expression, regex);
         return new ValueBuilder(newExp);
     }
 
@@ -190,12 +191,12 @@
      * @return the current builder
      */
     public ValueBuilder convertTo(Class<?> type) {
-        Expression newExp = ExpressionBuilder.convertTo(expression, type);
+        Expression newExp = ExpressionBuilder.convertToExpression(expression, type);
         return new ValueBuilder(newExp);
     }
 
     /**
-     * Converts the current value a String using the registered type converters
+     * Converts the current value to a String using the registered type converters
      * 
      * @return the current builder
      */
@@ -205,7 +206,7 @@
 
     /**
      * Appends the string evaluation of this expression with the given value
-     * 
+     *
      * @param value the value or expression to append
      * @return the current builder
      */
@@ -213,6 +214,18 @@
         return new ValueBuilder(ExpressionBuilder.append(expression, asExpression(value)));
     }
 
+    /**
+     * Sorts the current value using the given comparator. The current value must be convertable
+     * to a {@link List} to allow sorting using the comparator.
+     *
+     * @param comparator  the comparator used by sorting
+     * @return the current builder
+     */
+    public ValueBuilder sort(Comparator comparator) {
+        Expression newExp = ExpressionBuilder.sortExpression(expression, comparator);
+        return new ValueBuilder(newExp);
+    }
+
     // Implementation methods
     // -------------------------------------------------------------------------
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java?rev=746225&r1=746224&r2=746225&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguage.java Fri Feb 20 12:54:50 2009
@@ -96,7 +96,7 @@
         // system property
         remainder = ifStartsWithReturnRemainder("sys.", expression);
         if (remainder != null) {
-            return ExpressionBuilder.systemProperty(remainder);
+            return ExpressionBuilder.systemPropertyExpression(remainder);
         }
 
         // date: prefix

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguageSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguageSupport.java?rev=746225&r1=746224&r2=746225&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguageSupport.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/language/simple/SimpleLanguageSupport.java Fri Feb 20 12:54:50 2009
@@ -94,7 +94,7 @@
             right = simple != null ? createSimpleExpression(simple) : createConstantExpression(constant);
             // to support numeric comparions using > and < operators we must convert the right hand side
             // to the same type as the left
-            rightConverted = ExpressionBuilder.convertTo(right, left);
+            rightConverted = ExpressionBuilder.convertToExpression(right, left);
         }
 
         return new ExpressionAdapter() {

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java?rev=746225&r1=746224&r2=746225&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java Fri Feb 20 12:54:50 2009
@@ -20,6 +20,7 @@
 import java.util.Arrays;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Comparator;
 import java.util.HashSet;
 import java.util.LinkedList;
 import java.util.List;
@@ -65,6 +66,7 @@
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+import static org.apache.camel.builder.Builder.body;
 
 /**
  * Base class for processor types that most XML types extend.
@@ -1612,6 +1614,50 @@
     }
 
     /**
+     * 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
+     */
+    public Type sortBody(Comparator comparator) {
+        addOutput(new SortType(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}.
+     *
+     * @return the builder
+     */
+    public Type sortBody() {
+        return sortBody(null);
+    }
+
+    /**
+     * Sorts the expression using the given comparator
+     *
+     * @param expression  the expression, must be convertable to {@link List}
+     * @param comparator  the comparator to use for sorting
+     * @return the builder
+     */
+    public Type sort(Expression expression, Comparator comparator) {
+        addOutput(new SortType(expression, comparator));
+        return (Type) this;
+    }
+
+    /**
+     * 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 sort(Expression expression) {
+        return sort(expression, null);
+    }
+
+    /**
      * Enriches an exchange with additional data obtained from a
      * <code>resourceUri</code>.
      * 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java?rev=746225&r1=746224&r2=746225&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/RouteType.java Fri Feb 20 12:54:50 2009
@@ -301,4 +301,5 @@
     public void addInterceptor(InterceptorType interceptor) {
         getInterceptors().add(interceptor);
     }
+
 }

Copied: camel/trunk/camel-core/src/main/java/org/apache/camel/model/SortType.java (from r746146, camel/trunk/camel-core/src/main/java/org/apache/camel/model/ConvertBodyType.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SortType.java?p2=camel/trunk/camel-core/src/main/java/org/apache/camel/model/SortType.java&p1=camel/trunk/camel-core/src/main/java/org/apache/camel/model/ConvertBodyType.java&r1=746146&r2=746225&rev=746225&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/ConvertBodyType.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/SortType.java Fri Feb 20 12:54:50 2009
@@ -17,56 +17,79 @@
 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.RuntimeCamelException;
-import org.apache.camel.processor.ConvertBodyProcessor;
+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;
 
 /**
- * Represents an XML &lt;convertBodyTo/&gt; element
+ * Represents an XML &lt;sort/&gt; element
  */
-@XmlRootElement(name = "convertBodyTo")
+@XmlRootElement(name = "sort")
 @XmlAccessorType(XmlAccessType.FIELD)
-public class ConvertBodyType extends ProcessorType<ProcessorType> {
-    @XmlAttribute
-    private String type;
+public class SortType extends OutputType<SortType> {
     @XmlTransient
-    private Class typeClass;
+    private Comparator comparator;
+    @XmlAttribute(required = false)
+    private String comparatorRef;
+    @XmlElement(name = "expression", required = false)
+    private ExpressionSubElementType expression;
 
-    public ConvertBodyType() {
+    public SortType() {
     }
 
-    public ConvertBodyType(String type) {
-        setType(type);
+    public SortType(Expression expression) {
+        setExpression(expression);
     }
 
-    public ConvertBodyType(Class typeClass) {
-        setTypeClass(typeClass);
-        setType(typeClass.getName());
+    public SortType(Expression expression, Comparator comparator) {
+        this(expression);
+        this.comparator = comparator;
     }
 
     @Override
-    public String toString() {        
-        return "convertBodyTo[" + getType() + "]";
+    public String toString() {
+        return "sort[" + getExpression() + " by: " + (comparatorRef != null ? "ref:" + comparatorRef : comparator) + "]";
     }
 
     @Override
     public String getShortName() {
-        return "convertBodyTo";
+        return "sort";
     }
 
     @Override
     public Processor createProcessor(RouteContext routeContext) throws Exception {
-        return new ConvertBodyProcessor(getTypeClass());
+        // lookup in registry
+        if (ObjectHelper.isNotEmpty(comparatorRef)) {
+            comparator = routeContext.getCamelContext().getRegistry().lookup(comparatorRef, Comparator.class);
+        }
+
+        // if no comparator then default on to string representation
+        if (comparator == null) {
+            comparator = new Comparator() {
+                public int compare(Object o1, Object o2) {
+                    return ObjectHelper.compare(o1, o2);
+                }
+            };
+        }
+
+        // if no expression provided then default to body expression
+        if (getExpression() == null) {
+            setExpression(bodyExpression());
+        }
+
+        return new SortProcessor(getExpression(), getComparator());
     }
 
     @Override
@@ -74,54 +97,57 @@
         return Collections.EMPTY_LIST;
     }
 
-    protected Class createTypeClass() {
-        return ObjectHelper.loadClass(getType(), getClass().getClassLoader());
+    public Comparator getComparator() {
+        return comparator;
     }
 
-    public void setType(String type) {
-        this.type = type;
+    public void setComparator(Comparator comparator) {
+        this.comparator = comparator;
     }
 
-    public String getType() {
-        return type;
+    public String getComparatorRef() {
+        return comparatorRef;
     }
 
-    public void setTypeClass(Class typeClass) {
-        this.typeClass = typeClass;
+    public void setComparatorRef(String comparatorRef) {
+        this.comparatorRef = comparatorRef;
     }
 
-    public Class getTypeClass() {
-        if (typeClass == null) {
-            Class clazz = createTypeClass();
-            if (clazz == null) {
-                throw new RuntimeCamelException("Can't load the class with the class name: " + getType());
-            }
-            setTypeClass(clazz);
+    public Expression getExpression() {
+        if (expression == null) {
+            return null;
         }
-        return typeClass;
+        if (expression.getExpression() != null) {
+            return expression.getExpression();
+        }
+        return expression.getExpressionType();
+    }
+
+    public void setExpression(Expression expression) {
+        this.expression = new ExpressionSubElementType(expression);
     }
-    
-    // Fluent API
-    //-------------------------------------------------------------------------
+
     /**
-     * Sets the type class that you want ConvertBodyType to covert
+     * Sets the comparator to use for sorting
      *
-     * @param typeClass  the type class that you want to covert body instance to
+     * @param comparator  the comparator to use for sorting
      * @return the builder
      */
-    public ConvertBodyType typeClass(Class typeClass) {
-        setTypeClass(typeClass);
+    public SortType comparator(Comparator comparator) {
+        setComparator(comparator);
         return this;
     }
-    
+
     /**
-     * Sets the type class name that you want to covert body instance to
+     * Sets a reference to lookup for the comparator to use for sorting
      *
-     * @param type  the type class name
+     * @param ref reference for the comparator
      * @return the builder
      */
-    public ConvertBodyType type(String type) {
-        setType(type);
+    public SortType comparatorRef(String ref) {
+        setComparatorRef(ref);
         return this;
     }
-}
+
+
+}
\ No newline at end of file

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

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

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/TokenizerExpression.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/TokenizerExpression.java?rev=746225&r1=746224&r2=746225&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/TokenizerExpression.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/language/TokenizerExpression.java Fri Feb 20 12:54:50 2009
@@ -26,7 +26,7 @@
 import org.apache.camel.spi.RouteContext;
 import static org.apache.camel.builder.Builder.body;
 import static org.apache.camel.builder.Builder.header;
-import static org.apache.camel.builder.ExpressionBuilder.regexTokenize;
+import static org.apache.camel.builder.ExpressionBuilder.regexTokenizeExpression;
 import static org.apache.camel.builder.ExpressionBuilder.tokenizeExpression;
 import static org.apache.camel.builder.PredicateBuilder.toPredicate;
 
@@ -76,7 +76,7 @@
     public Expression createExpression(RouteContext routeContext) {
         Expression exp = headerName == null ? body() : header(headerName);
         if (regex != null && regex) {
-            return regexTokenize(exp, token);
+            return regexTokenizeExpression(exp, token);
         } else {
             return tokenizeExpression(exp, token);
         }

Added: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SortProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SortProcessor.java?rev=746225&view=auto
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SortProcessor.java (added)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/SortProcessor.java Fri Feb 20 12:54:50 2009
@@ -0,0 +1,59 @@
+/**
+ * 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 java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Expression;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+
+/**
+ * A processor that sorts the expression using a comparator
+ */
+public class SortProcessor implements Processor {
+
+    private final Expression expression;
+    private final Comparator comparator;
+
+    public SortProcessor(Expression expression, Comparator comparator) {
+        this.expression = expression;
+        this.comparator = comparator;
+    }
+
+    @SuppressWarnings("unchecked")
+    public void process(Exchange exchange) throws Exception {
+        Message in = exchange.getIn();
+
+        List list = expression.evaluate(exchange, List.class);
+        Collections.sort(list, comparator);
+
+        if (exchange.getPattern().isOutCapable()) {
+            Message out = exchange.getOut();
+            out.copyFrom(in);
+            out.setBody(list);
+        } else {
+            in.setBody(list);
+        }
+    }
+
+}
+
+

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

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

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/view/GraphGeneratorSupport.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/view/GraphGeneratorSupport.java?rev=746225&r1=746224&r2=746225&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/view/GraphGeneratorSupport.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/view/GraphGeneratorSupport.java Fri Feb 20 12:54:50 2009
@@ -16,6 +16,17 @@
  */
 package org.apache.camel.view;
 
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.camel.CamelContext;
 import org.apache.camel.model.ChoiceType;
 import org.apache.camel.model.FromType;
@@ -28,17 +39,6 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
 /**
  * @version $Revision$
  */

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=746225&r1=746224&r2=746225&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 Fri Feb 20 12:54:50 2009
@@ -59,6 +59,7 @@
 SetOutHeaderType
 SetPropertyType
 SplitterType
+SortType
 StopType
 ThrottlerType
 ThreadType

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ExpressionBuilderTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ExpressionBuilderTest.java?rev=746225&r1=746224&r2=746225&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ExpressionBuilderTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/builder/ExpressionBuilderTest.java Fri Feb 20 12:54:50 2009
@@ -18,6 +18,7 @@
 
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Comparator;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Expression;
@@ -26,13 +27,7 @@
 import org.apache.camel.TestSupport;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.impl.DefaultExchange;
-
-import static org.apache.camel.builder.ExpressionBuilder.bodyExpression;
-import static org.apache.camel.builder.ExpressionBuilder.constantExpression;
-import static org.apache.camel.builder.ExpressionBuilder.headerExpression;
-import static org.apache.camel.builder.ExpressionBuilder.regexReplaceAll;
-import static org.apache.camel.builder.ExpressionBuilder.regexTokenize;
-import static org.apache.camel.builder.ExpressionBuilder.tokenizeExpression;
+import static org.apache.camel.builder.ExpressionBuilder.*;
 import static org.apache.camel.builder.PredicateBuilder.contains;
 
 /**
@@ -42,15 +37,15 @@
     protected Exchange exchange = new DefaultExchange(new DefaultCamelContext());
 
     public void testRegexTokenize() throws Exception {
-        Expression expression = regexTokenize(headerExpression("location"), ",");
+        Expression expression = regexTokenizeExpression(headerExpression("location"), ",");
         ArrayList expected = new ArrayList(Arrays.asList(new String[] {"Islington", "London", "UK"}));
         assertExpression(expression, exchange, expected);
 
-        Predicate predicate = contains(regexTokenize(headerExpression("location"), ","),
+        Predicate predicate = contains(regexTokenizeExpression(headerExpression("location"), ","),
                                                  constantExpression("London"));
         assertPredicate(predicate, exchange, true);
 
-        predicate = contains(regexTokenize(headerExpression("location"), ","),
+        predicate = contains(regexTokenizeExpression(headerExpression("location"), ","),
                              constantExpression("Manchester"));
         assertPredicate(predicate, exchange, false);
     }
@@ -80,13 +75,21 @@
     }
 
     public void testTokenizeLines() throws Exception {
-        Expression expression = regexTokenize(bodyExpression(), "[\r|\n]");
+        Expression expression = regexTokenizeExpression(bodyExpression(), "[\r|\n]");
         exchange.getIn().setBody("Hello World\nBye World\rSee you again");
 
         ArrayList expected = new ArrayList(Arrays.asList(new String[] {"Hello World", "Bye World", "See you again"}));
         assertExpression(expression, exchange, expected);
     }
 
+    public void testSortLines() throws Exception {
+        Expression expression = sortExpression(body().tokenize(",").getExpression(), new SortByName());
+        exchange.getIn().setBody("Jonathan,Claus,James,Hadrian");
+
+        ArrayList expected = new ArrayList(Arrays.asList(new String[] {"Claus", "Hadrian", "James", "Jonathan"}));
+        assertExpression(expression, exchange, expected);
+    }
+
     @Override
     protected void setUp() throws Exception {
         super.setUp();
@@ -95,4 +98,12 @@
         in.setHeader("name", "James");
         in.setHeader("location", "Islington,London,UK");
     }
+
+    private class SortByName implements Comparator<String> {
+
+        public int compare(java.lang.String o1, java.lang.String o2) {
+            return o1.compareToIgnoreCase(o2);
+        }
+    }
+
 }

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SortBodyTest.java (from r746146, camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SortBodyTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SortBodyTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java&r1=746146&r2=746225&rev=746225&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/ConvertBodyTest.java (original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SortBodyTest.java Fri Feb 20 12:54:50 2009
@@ -17,28 +17,36 @@
 
 package org.apache.camel.processor;
 
+import java.util.List;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 
-public class ConvertBodyTest extends ContextTestSupport {
-    public void testConvertToInteger() throws Exception {
+public class SortBodyTest extends ContextTestSupport {
+
+    public void testSortBody() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
 
-        MockEndpoint resultEndpoint = resolveMandatoryEndpoint("mock:result",
-                MockEndpoint.class);
-        resultEndpoint.expectedBodiesReceived(11);
+        template.sendBody("direct:start", new String[]{"Hadrian", "William", "Claus"});
 
-        template.sendBody("direct:start", "11");
+        assertMockEndpointsSatisfied();
 
-        resultEndpoint.assertIsSatisfied();
+        List list = mock.getExchanges().get(0).getIn().getBody(List.class);
+        assertEquals("Claus", list.get(0));
+        assertEquals("Hadrian", list.get(1));
+        assertEquals("William", list.get(2));
     }
 
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                from("direct:start").convertBodyTo(Integer.class).to("mock:result");
+                // START SNIPPET: e1
+                from("direct:start").sortBody().to("mock:result");
+                // END SNIPPET: e1
             }
         };
     }
 
-}
+}
\ No newline at end of file

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SortExpressionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SortExpressionTest.java?rev=746225&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SortExpressionTest.java (added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SortExpressionTest.java Fri Feb 20 12:54:50 2009
@@ -0,0 +1,84 @@
+/**
+ * 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 java.util.Comparator;
+import java.util.List;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.util.ObjectHelper;
+
+public class SortExpressionTest extends ContextTestSupport {
+
+    public void testSortBody() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+
+        template.sendBody("direct:start", "Hadrian,William,Claus");
+
+        assertMockEndpointsSatisfied();
+
+        List list = mock.getExchanges().get(0).getIn().getBody(List.class);
+        assertEquals("Claus", list.get(0));
+        assertEquals("Hadrian", list.get(1));
+        assertEquals("William", list.get(2));
+    }
+
+    public void testSortReverse() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:result");
+        mock.expectedMessageCount(1);
+
+        template.sendBody("direct:reverse", "Hadrian,William,Claus");
+
+        assertMockEndpointsSatisfied();
+
+        List list = mock.getExchanges().get(0).getIn().getBody(List.class);
+        assertEquals("William", list.get(0));
+        assertEquals("Hadrian", list.get(1));
+        assertEquals("Claus", list.get(2));
+    }
+
+    protected RouteBuilder createRouteBuilder() {
+        return new RouteBuilder() {
+            public void configure() {
+                // START SNIPPET: e1
+                from("direct:start").sort(body().tokenize(",")).to("mock:result");
+                // END SNIPPET: e1
+
+                // START SNIPPET: e2
+                from("direct:reverse").sort(body().tokenize(","), new MyReverseComparator()).to("mock:result");
+                // END SNIPPET: e2
+            }
+        };
+    }
+
+    // START SNIPPET: e3
+    public static class MyReverseComparator implements Comparator {
+
+        // must have default constructor when used by spring bean testing
+        public MyReverseComparator() {
+        }
+
+        public int compare(Object o1, Object o2) {
+            // just reverse it for unit testing
+            return ObjectHelper.compare(o1, o2) * -1;
+        }
+    }
+    // END SNIPPET: e3
+}
\ No newline at end of file

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

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

Copied: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSortBodyTest.java (from r746146, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetBodyTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSortBodyTest.java?p2=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSortBodyTest.java&p1=camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetBodyTest.java&r1=746146&r2=746225&rev=746225&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSetBodyTest.java (original)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSortBodyTest.java Fri Feb 20 12:54:50 2009
@@ -17,23 +17,12 @@
 package org.apache.camel.spring.processor;
 
 import org.apache.camel.CamelContext;
-import org.apache.camel.ContextTestSupport;
-import org.apache.camel.component.mock.MockEndpoint;
-
+import org.apache.camel.processor.SortBodyTest;
 import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
 
-public class SpringSetBodyTest extends ContextTestSupport {
-
-    public void testSendAMessageWhosInBodyIsTransformed() throws Exception {
-        MockEndpoint resultEndpoint = getMockEndpoint("mock:end");
-        resultEndpoint.expectedBodiesReceived("Hello World!");
-
-        sendBody("direct:start", "Hello");
-
-        resultEndpoint.assertIsSatisfied();
-    }
+public class SpringSortBodyTest extends SortBodyTest {
 
     protected CamelContext createCamelContext() throws Exception {
-        return createSpringCamelContext(this, "org/apache/camel/spring/processor/setBody.xml");
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/sortBodyTest.xml");
     }
-}
+}
\ No newline at end of file

Added: camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSortExpressionTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSortExpressionTest.java?rev=746225&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSortExpressionTest.java (added)
+++ camel/trunk/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringSortExpressionTest.java Fri Feb 20 12:54:50 2009
@@ -0,0 +1,28 @@
+/**
+ * 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.SortExpressionTest;
+import static org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringSortExpressionTest extends SortExpressionTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, "org/apache/camel/spring/processor/sortExpressionTest.xml");
+    }
+}
\ No newline at end of file

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

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

Copied: camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortBodyTest.xml (from r746146, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setBody.xml)
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortBodyTest.xml?p2=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortBodyTest.xml&p1=camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setBody.xml&r1=746146&r2=746225&rev=746225&view=diff
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/setBody.xml (original)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortBodyTest.xml Fri Feb 20 12:54:50 2009
@@ -22,16 +22,15 @@
        http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd
     ">
 
-  <!-- START SNIPPET: example -->
-  <camelContext xmlns="http://camel.apache.org/schema/spring">
-    <route>
-      <from uri="direct:start"/>
-      <setBody>
-        <simple>${in.body} World!</simple>
-      </setBody>
-      <to uri="mock:end"/>
-    </route>
-  </camelContext>
-  <!-- END SNIPPET: example -->
+    <!-- START SNIPPET: example -->
+    <camelContext xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="direct:start"/>
+            <!-- will default sort the body using a default comparator -->
+            <sort/>
+            <to uri="mock:result"/>
+        </route>
+    </camelContext>
+    <!-- END SNIPPET: example -->
 
 </beans>

Added: 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=746225&view=auto
==============================================================================
--- camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortExpressionTest.xml (added)
+++ camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/sortExpressionTest.xml Fri Feb 20 12:54:50 2009
@@ -0,0 +1,53 @@
+<?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 xmlns="http://camel.apache.org/schema/spring">
+        <route>
+            <from uri="direct:start"/>
+            <!-- will tokenize the body by comma and sort it -->
+            <sort>
+                <expression>
+                    <tokenizer token=","/>
+                </expression>
+            </sort>
+            <to uri="mock:result"/>
+        </route>
+
+        <route>
+            <from uri="direct:reverse"/>
+            <!-- will tokenize the body by comma and sort it using the comparator -->
+            <sort comparatorRef="myReverseComparator">
+                <expression>
+                    <tokenizer token=","/>
+                </expression>
+            </sort>
+            <to uri="mock:result"/>
+        </route>
+    </camelContext>
+
+    <bean id="myReverseComparator" class="org.apache.camel.processor.SortExpressionTest$MyReverseComparator"/>
+    <!-- END SNIPPET: example -->
+
+</beans>

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

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

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



Mime
View raw message