You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2008/12/19 07:59:08 UTC

svn commit: r727952 - /activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/

Author: ningjiang
Date: Thu Dec 18 22:59:08 2008
New Revision: 727952

URL: http://svn.apache.org/viewvc?rev=727952&view=rev
Log:
CAMEL-1117 improve Java DSL to reduce methods in ProcessorType

Modified:
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FilterType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/LoopType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/MulticastType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RecipientListType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetBodyType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetHeaderType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetOutHeaderType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetPropertyType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SplitterType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TransformType.java
    activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/WhenType.java

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java?rev=727952&r1=727951&r2=727952&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/DelayerType.java Thu Dec 18 22:59:08 2008
@@ -23,6 +23,7 @@
 
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
+import org.apache.camel.builder.ExpressionClause;
 import org.apache.camel.model.language.ExpressionType;
 import org.apache.camel.processor.Delayer;
 import org.apache.camel.spi.RouteContext;
@@ -67,6 +68,14 @@
         setDelayTime(delay);
         return this;
     }
+    
+    /**
+     * Set the expression that the delayer will use
+     * @return the builder
+     */
+    public ExpressionClause<DelayerType> expression() {
+        return ExpressionClause.createAndSetExpression(this);
+    }
 
     @Override
     public String getShortName() {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FilterType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FilterType.java?rev=727952&r1=727951&r2=727952&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FilterType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/FilterType.java Thu Dec 18 22:59:08 2008
@@ -21,6 +21,7 @@
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.camel.Predicate;
+import org.apache.camel.builder.ExpressionClause;
 import org.apache.camel.model.language.ExpressionType;
 import org.apache.camel.processor.FilterProcessor;
 import org.apache.camel.spi.RouteContext;
@@ -59,4 +60,14 @@
     public FilterProcessor createProcessor(RouteContext routeContext) throws Exception {
         return createFilterProcessor(routeContext);
     }
+    
+    // Fluent API
+    //-------------------------------------------------------------------------
+    /**
+     * Set the expression that this FilterType will use
+     * @return the builder
+     */
+    public ExpressionClause<FilterType> expression() {
+        return ExpressionClause.createAndSetExpression(this);
+    }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerType.java?rev=727952&r1=727951&r2=727952&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/IdempotentConsumerType.java Thu Dec 18 22:59:08 2008
@@ -24,6 +24,7 @@
 
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
+import org.apache.camel.builder.ExpressionClause;
 import org.apache.camel.processor.idempotent.IdempotentConsumer;
 import org.apache.camel.spi.IdempotentRepository;
 import org.apache.camel.spi.RouteContext;
@@ -62,6 +63,14 @@
     // Fluent API
     //-------------------------------------------------------------------------
     /**
+     * Set the expression that IdempotentConsumerType will use
+     * @return the builder
+     */
+    public ExpressionClause<IdempotentConsumerType> expression() {
+        return ExpressionClause.createAndSetExpression(this);
+    }
+    
+    /**
      * Sets the reference name of the message id repository
      *
      * @param messageIdRepositoryRef  the reference name of message id repository

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/LoopType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/LoopType.java?rev=727952&r1=727951&r2=727952&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/LoopType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/LoopType.java Thu Dec 18 22:59:08 2008
@@ -22,6 +22,7 @@
 
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
+import org.apache.camel.builder.ExpressionClause;
 import org.apache.camel.model.language.ExpressionType;
 import org.apache.camel.processor.LoopProcessor;
 import org.apache.camel.spi.RouteContext;
@@ -50,6 +51,8 @@
             setExpression(new ExpressionType(expr));
         }
     }
+    
+    
     @Override
     public String toString() {
         return "Loop[" + getExpression() + " -> " + getOutputs() + "]";
@@ -66,4 +69,14 @@
             getExpression().createExpression(routeContext),
             routeContext.createProcessor(this));
     }
+    
+     // Fluent API
+    //-------------------------------------------------------------------------
+    /**
+     * Set the expression that LoopType will use
+     * @return the builder
+     */
+    public ExpressionClause<LoopType> expression() {
+        return ExpressionClause.createAndSetExpression(this);
+    }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/MulticastType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/MulticastType.java?rev=727952&r1=727951&r2=727952&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/MulticastType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/MulticastType.java Thu Dec 18 22:59:08 2008
@@ -80,10 +80,20 @@
     }
     
     /**
+     * use a thread pool to do the multicasting work
+     *     
+     * @return the builder
+     */
+    public MulticastType parallelProcessing() {
+        setParallelProcessing(parallelProcessing);
+        return this;
+    }
+    
+    /**
      * Set the multicasting action's thread model
      * @param parallelProcessing 
-     * if it is true the Splitter will use a thread pool to do the multicasting work; 
-     * if it is false the Splitter only do the multicasting work in the calling thread.
+     * if it is true the MulticastType will use a thread pool to do the multicasting work; 
+     * if it is false the MulticastType only do the multicasting work in the calling thread.
      *
      * @return the builder
      */

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java?rev=727952&r1=727951&r2=727952&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ProcessorType.java Thu Dec 18 22:59:08 2008
@@ -537,6 +537,19 @@
         addOutput(answer);
         return this;
     }
+    
+    /**
+     * <a href="http://activemq.apache.org/camel/idempotent-consumer.html">Idempotent consumer EIP:</a>
+     * Creates an {@link org.apache.camel.processor.idempotent.IdempotentConsumer IdempotentConsumer}
+     * to avoid duplicate messages
+     *      
+     * @return the builder
+     */
+    public IdempotentConsumerType idempotentConsumer() {
+        IdempotentConsumerType answer = new IdempotentConsumerType();
+        addOutput(answer);
+        return answer;
+    }
 
     /**
      * <a href="http://activemq.apache.org/camel/idempotent-consumer.html">Idempotent consumer EIP:</a>
@@ -778,6 +791,7 @@
      * @param expression  the expression on which to split
      * @param aggregationStrategy  the strategy used to aggregate responses for every part
      * @return the builder
+     * @deprecated will be removed in Camel 2.0
      */
     public SplitterType split(Expression expression, AggregationStrategy aggregationStrategy) {
         SplitterType answer = new SplitterType(expression);
@@ -794,6 +808,7 @@
      *
      * @param aggregationStrategy  the strategy used to aggregate responses for every part
      * @return the expression clause for the expression on which to split
+     * @deprecated will be removed in Camel 2.0
      */
     public ExpressionClause<SplitterType> split(AggregationStrategy aggregationStrategy) {
         SplitterType answer = new SplitterType();
@@ -811,6 +826,7 @@
      * @param expression the expression on which to split
      * @param parallelProcessing if is <tt>true</tt> camel will fork thread to call the endpoint producer
      * @return the builder
+     * @deprecated will be removed in Camel 2.0
      */
     public SplitterType split(Expression expression, boolean parallelProcessing) {
         SplitterType answer = new SplitterType(expression);
@@ -829,6 +845,7 @@
      * @param parallelProcessing if is <tt>true</tt> camel will fork thread to call the endpoint producer
      * @param executor override the default {@link Executor}
      * @return the builder
+     * @deprecated will be removed in Camel 2.0
      */
     public SplitterType split(Expression expression, boolean parallelProcessing,
                                  Executor executor) {
@@ -847,6 +864,7 @@
      *
      * @param parallelProcessing if is <tt>true</tt> camel will fork thread to call the endpoint producer
      * @return the expression clause for the expression on which to split
+     * @deprecated will be removed in Camel 2.0
      */
     public ExpressionClause<SplitterType> split(boolean parallelProcessing) {
         SplitterType answer = new SplitterType();
@@ -865,6 +883,7 @@
      * @param parallelProcessing if is <tt>true</tt> camel will fork thread to call the endpoint producer
      * @param executor override the default {@link Executor}
      * @return the expression clause for the expression on which to split
+     * @deprecated will be removed in Camel 2.0
      */
     public ExpressionClause<SplitterType> split(boolean parallelProcessing, Executor executor) {
         SplitterType answer = new SplitterType();
@@ -884,6 +903,7 @@
      * @param aggregationStrategy the strategy used to aggregate responses for every part
      * @param parallelProcessing if is <tt>true</tt> camel will fork thread to call the endpoint producer
      * @return the builder
+     * @deprecated will be removed in Camel 2.0
      */
     public SplitterType split(Expression expression, AggregationStrategy aggregationStrategy,
                                  boolean parallelProcessing) {
@@ -905,6 +925,7 @@
      * @param parallelProcessing if is <tt>true</tt> camel will fork thread to call the endpoint producer
      * @param executor override the default {@link Executor}
      * @return the builder
+     * @deprecated will be removed in Camel 2.0
      */
     public SplitterType split(Expression expression, AggregationStrategy aggregationStrategy,
                                  boolean parallelProcessing, Executor executor) {
@@ -944,6 +965,7 @@
      * @param parallelProcessing if is <tt>true</tt> camel will fork thread to call the endpoint producer
      * @param executor override the default {@link Executor}
      * @return the expression clause for the expression on which to split
+     * @deprecated will be removed in Camel 2.0
      */
     public ExpressionClause<SplitterType> split(AggregationStrategy aggregationStrategy, boolean parallelProcessing,
                                                    Executor executor) {

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RecipientListType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RecipientListType.java?rev=727952&r1=727951&r2=727952&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RecipientListType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/RecipientListType.java Thu Dec 18 22:59:08 2008
@@ -22,6 +22,7 @@
 
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
+import org.apache.camel.builder.ExpressionClause;
 import org.apache.camel.model.language.ExpressionType;
 import org.apache.camel.processor.RecipientList;
 import org.apache.camel.spi.RouteContext;
@@ -60,4 +61,14 @@
     public Processor createProcessor(RouteContext routeContext) throws Exception {
         return new RecipientList(getExpression().createExpression(routeContext));
     }
+    
+    // Fluent API
+    //-------------------------------------------------------------------------
+    /**
+     * Set the expression that RecipientListType will use
+     * @return the builder
+     */
+    public ExpressionClause<RecipientListType> expression() {
+        return ExpressionClause.createAndSetExpression(this);
+    }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetBodyType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetBodyType.java?rev=727952&r1=727951&r2=727952&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetBodyType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetBodyType.java Thu Dec 18 22:59:08 2008
@@ -23,6 +23,7 @@
 
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
+import org.apache.camel.builder.ExpressionClause;
 import org.apache.camel.builder.ProcessorBuilder;
 import org.apache.camel.spi.RouteContext;
 
@@ -55,4 +56,14 @@
         Expression expr = getExpression().createExpression(routeContext);
         return ProcessorBuilder.setBody(expr);
     }
+    
+     // Fluent API
+    //-------------------------------------------------------------------------
+    /**
+     * Set the expression that SetBodyType class will use
+     * @return the builder
+     */
+    public ExpressionClause<SetBodyType> expression() {
+        return ExpressionClause.createAndSetExpression(this);
+    }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetHeaderType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetHeaderType.java?rev=727952&r1=727951&r2=727952&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetHeaderType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetHeaderType.java Thu Dec 18 22:59:08 2008
@@ -24,6 +24,7 @@
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.ExpressionBuilder;
+import org.apache.camel.builder.ExpressionClause;
 import org.apache.camel.builder.ProcessorBuilder;
 import org.apache.camel.model.language.ExpressionType;
 import org.apache.camel.spi.RouteContext;
@@ -80,4 +81,14 @@
     public String getHeaderName() {
         return headerName;
     }
+    
+    // Fluent API
+    //-------------------------------------------------------------------------
+    /**
+     * Set the expression that SetHeaderType will use
+     * @return the builder
+     */
+    public ExpressionClause<SetHeaderType> expression() {
+        return ExpressionClause.createAndSetExpression(this);
+    }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetOutHeaderType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetOutHeaderType.java?rev=727952&r1=727951&r2=727952&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetOutHeaderType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetOutHeaderType.java Thu Dec 18 22:59:08 2008
@@ -23,6 +23,7 @@
 
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
+import org.apache.camel.builder.ExpressionClause;
 import org.apache.camel.builder.ProcessorBuilder;
 import org.apache.camel.model.language.ExpressionType;
 import org.apache.camel.spi.RouteContext;
@@ -74,4 +75,14 @@
     public String getHeaderName() {
         return headerName;
     }
+    
+    // Fluent API
+    //-------------------------------------------------------------------------
+    /**
+     * Set the expression that SetOutHeaderType will use
+     * @return the builder
+     */
+    public ExpressionClause<SetOutHeaderType> expression() {
+        return ExpressionClause.createAndSetExpression(this);
+    }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetPropertyType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetPropertyType.java?rev=727952&r1=727951&r2=727952&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetPropertyType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetPropertyType.java Thu Dec 18 22:59:08 2008
@@ -24,6 +24,7 @@
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.ExpressionBuilder;
+import org.apache.camel.builder.ExpressionClause;
 import org.apache.camel.builder.ProcessorBuilder;
 import org.apache.camel.model.language.ExpressionType;
 import org.apache.camel.spi.RouteContext;
@@ -80,4 +81,14 @@
     public String getPropertyName() {
         return propertyName;
     }
+    
+ // Fluent API
+    //-------------------------------------------------------------------------
+    /**
+     * Set the expression that SetPropertyType will use
+     * @return the builder
+     */
+    public ExpressionClause<SetPropertyType> expression() {
+        return ExpressionClause.createAndSetExpression(this);
+    }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SplitterType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SplitterType.java?rev=727952&r1=727951&r2=727952&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SplitterType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SplitterType.java Thu Dec 18 22:59:08 2008
@@ -29,6 +29,7 @@
 
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
+import org.apache.camel.builder.ExpressionClause;
 import org.apache.camel.model.language.ExpressionType;
 import org.apache.camel.processor.Splitter;
 import org.apache.camel.processor.aggregate.AggregationStrategy;
@@ -89,6 +90,13 @@
     // Fluent API
     // -------------------------------------------------------------------------
     /**
+     * Set the expression that the Splitter will use
+     * @return the builder
+     */
+    public ExpressionClause<SplitterType> expression() {
+        return ExpressionClause.createAndSetExpression(this);
+    }
+    /**
      * Set the spliter's aggregationStrategy
      * @param aggregationStrategy 
      *
@@ -100,6 +108,16 @@
     }
     
     /**
+     * Doing the splitting work parallelly
+     *
+     * @return the builder
+     */
+    public SplitterType parallelProcessing() {
+        setParallelProcessing(true);
+        return this;
+    }
+    
+    /**
      * Set the splitting action's thread model
      * @param parallelProcessing 
      * if it is true the Splitter will use a thread pool to do the splitting work; 

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TransformType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TransformType.java?rev=727952&r1=727951&r2=727952&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TransformType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/TransformType.java Thu Dec 18 22:59:08 2008
@@ -22,6 +22,7 @@
 
 import org.apache.camel.Expression;
 import org.apache.camel.Processor;
+import org.apache.camel.builder.ExpressionClause;
 import org.apache.camel.processor.TransformProcessor;
 import org.apache.camel.spi.RouteContext;
 
@@ -56,4 +57,14 @@
 
         return new TransformProcessor(expr, childProcessor);
     }
+    
+    // Fluent API
+    //-------------------------------------------------------------------------
+    /**
+     * Set the expression that TransformType will use
+     * @return the builder
+     */
+    public ExpressionClause<TransformType> expression() {
+        return ExpressionClause.createAndSetExpression(this);
+    }
 }

Modified: activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/WhenType.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/WhenType.java?rev=727952&r1=727951&r2=727952&view=diff
==============================================================================
--- activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/WhenType.java (original)
+++ activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/WhenType.java Thu Dec 18 22:59:08 2008
@@ -19,6 +19,7 @@
 import javax.xml.bind.annotation.XmlRootElement;
 
 import org.apache.camel.Predicate;
+import org.apache.camel.builder.ExpressionClause;
 import org.apache.camel.model.language.ExpressionType;
 import org.apache.camel.processor.FilterProcessor;
 import org.apache.camel.spi.RouteContext;
@@ -29,7 +30,7 @@
  * @version $Revision$
  */
 @XmlRootElement(name = "when")
-public class WhenType<Type extends ProcessorType> extends ExpressionNode {
+public class WhenType extends ExpressionNode {
 
     public WhenType() {
     }
@@ -56,4 +57,14 @@
     public FilterProcessor createProcessor(RouteContext routeContext) throws Exception {
         return createFilterProcessor(routeContext);
     }
+    
+    // Fluent API
+    //-------------------------------------------------------------------------
+    /**
+     * Set the expression that WhenType will use
+     * @return the builder
+     */
+    public ExpressionClause<WhenType> expression() {
+        return ExpressionClause.createAndSetExpression(this);
+    }
 }