Author: ningjiang
Date: Wed Dec 17 05:27:14 2008
New Revision: 727375

URL: http://svn.apache.org/viewvc?rev=727375&view=rev
Log:
CAMEL-1192  Better fluent API supporting in the core module

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/MulticastType.java
    
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetExchangePatternType.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/ThrottlerType.java
    
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MultiCastAggregatorTest.java
    
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterWithCustomThreadPoolExecutorTest.java
    
activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/LoanBroker.java
    
activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/webservice/version/LoanBroker.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=727375&r1=727374&r2=727375&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
 Wed Dec 17 05:27:14 2008
@@ -59,6 +59,14 @@
     public String toString() {
         return "Delayer[" + getExpression() + " -> " + getOutputs() + "]";
     }
+    
+    // Fluent API
+    // 
-------------------------------------------------------------------------
+    
+    public DelayerType delayTime(Long delay) {
+        setDelayTime(delay);
+        return this;
+    }
 
     @Override
     public String getShortName() {
@@ -71,7 +79,8 @@
 
     public void setDelayTime(Long delay) {
         this.delayTime = delay;
-    }
+    }   
+    
 
     @Override
     public Processor createProcessor(RouteContext routeContext) throws 
Exception {

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=727375&r1=727374&r2=727375&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
 Wed Dec 17 05:27:14 2008
@@ -66,6 +66,43 @@
         return createOutputsProcessor(routeContext);
     }
 
+    // Fluent API
+    // 
-------------------------------------------------------------------------
+    /**
+     * Set the multicasting aggregationStrategy
+     * @param aggregationStrategy 
+     *
+     * @return the builder
+     */
+    public MulticastType aggregationStrategy(AggregationStrategy 
aggregationStrategy) {
+        setAggregationStrategy(aggregationStrategy);
+        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.
+     *
+     * @return the builder
+     */
+    public MulticastType parallelProcessing(boolean parallelProcessing) {
+        setParallelProcessing(parallelProcessing);
+        return this;
+    }
+    
+    /**
+     * Setting the executor for executing the multicasting action. 
+     * @param executor 
+     *
+     * @return the builder
+     */
+    public MulticastType executor(Executor executor) {
+        setExecutor(executor);
+        return this;
+    }
+    
     protected Processor createCompositeProcessor(RouteContext routeContext, 
List<Processor> list) {
         if (aggregationStrategy == null && strategyRef != null) {
             aggregationStrategy = routeContext.lookup(strategyRef, 
AggregationStrategy.class);
@@ -92,18 +129,16 @@
         return parallelProcessing != null ? parallelProcessing : false;
     }
 
-    public MulticastType setParallelProcessing(boolean parallelProcessing) {
-        this.parallelProcessing = parallelProcessing;
-        return this;
+    public void setParallelProcessing(boolean parallelProcessing) {
+        this.parallelProcessing = parallelProcessing;        
     }
 
     public Executor getExecutor() {
         return executor;
     }
 
-    public MulticastType setThreadPoolExecutor(Executor executor) {
-        this.executor = executor;
-        return this;
+    public void setExecutor(Executor executor) {
+        this.executor = executor;        
     }
 
     @Override

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetExchangePatternType.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetExchangePatternType.java?rev=727375&r1=727374&r2=727375&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetExchangePatternType.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/SetExchangePatternType.java
 Wed Dec 17 05:27:14 2008
@@ -51,6 +51,10 @@
         this.pattern = pattern;
     }
 
+    public SetExchangePatternType pattern(ExchangePattern pattern) {
+        setPattern(pattern);
+        return this;
+    }
 
     public ExchangePattern getPattern() {
         return pattern;

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=727375&r1=727374&r2=727375&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
 Wed Dec 17 05:27:14 2008
@@ -86,6 +86,54 @@
                 isParallelProcessing(), executor, streaming);
     }
     
+    // Fluent API
+    // 
-------------------------------------------------------------------------
+    /**
+     * Set the spliter's aggregationStrategy
+     * @param aggregationStrategy 
+     *
+     * @return the builder
+     */
+    public SplitterType aggregationStrategy(AggregationStrategy 
aggregationStrategy) {
+        setAggregationStrategy(aggregationStrategy);
+        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; 
+     * if it is false the Splitter only do the splitting work in the calling 
thread.
+     *
+     * @return the builder
+     */
+    public SplitterType parallelProcessing(boolean parallelProcessing) {
+        setParallelProcessing(parallelProcessing);
+        return this;
+    }
+    
+    /**
+     * Enables streaming. 
+     * See {...@link SplitterType#setStreaming(boolean)} for more information
+     *
+     * @return the builder
+     */
+    public SplitterType streaming() {
+        setStreaming(true);
+        return this;
+    }
+    
+    /**
+     * Setting the executor for executing the splitting action. 
+     * @param executor 
+     *
+     * @return the builder
+     */
+    public SplitterType executor(Executor executor) {
+        setExecutor(executor);
+        return this;
+    }
+    
     public AggregationStrategy getAggregationStrategy() {
         return aggregationStrategy;
     }
@@ -116,17 +164,6 @@
     public void setStreaming(boolean streaming) {
         this.streaming = streaming;
     }
-    
-    /**
-     * Enables streaming. 
-     * See {...@link SplitterType#setStreaming(boolean)} for more information
-     *
-     * @return the builder
-     */
-    public SplitterType streaming() {
-        setStreaming(true);
-        return this;
-    }
 
     private Executor createThreadPoolExecutor(RouteContext routeContext) {
         Executor executor = getExecutor();

Modified: 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java?rev=727375&r1=727374&r2=727375&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/main/java/org/apache/camel/model/ThrottlerType.java
 Wed Dec 17 05:27:14 2008
@@ -83,7 +83,18 @@
      * @return the builder
      */
     public ThrottlerType timePeriodMillis(long timePeriodMillis) {
-        this.timePeriodMillis = timePeriodMillis;
+        setTimePeriodMillis(timePeriodMillis);
+        return this;
+    }
+    
+    /**
+     * Sets the time period during which the maximum request count per period
+     *
+     * @param maximumRequestsPerPeriod  the maximum request count number per 
time period
+     * @return the builder
+     */
+    public ThrottlerType maximumRequestsPerPeriod(Long 
maximumRequestsPerPeriod) {
+        setMaximumRequestsPerPeriod(maximumRequestsPerPeriod);
         return this;
     }
 

Modified: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MultiCastAggregatorTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MultiCastAggregatorTest.java?rev=727375&r1=727374&r2=727375&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MultiCastAggregatorTest.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/MultiCastAggregatorTest.java
 Wed Dec 17 05:27:14 2008
@@ -72,7 +72,7 @@
                 // START SNIPPET: example
                 // The message will be sent parallelly to the endpoints
                 from("direct:parallel")
-                    .multicast(new BodyOutAggregatingStrategy(), 
true).setThreadPoolExecutor(tpExecutor)
+                    .multicast(new BodyOutAggregatingStrategy(), 
true).executor(tpExecutor)
                         .to("direct:x", "direct:y", "direct:z");
                 // Multicast the message in a sequential way
                 from("direct:sequential").multicast(new 
BodyOutAggregatingStrategy()).to("direct:x", "direct:y", "direct:z");

Modified: 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterWithCustomThreadPoolExecutorTest.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterWithCustomThreadPoolExecutorTest.java?rev=727375&r1=727374&r2=727375&view=diff
==============================================================================
--- 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterWithCustomThreadPoolExecutorTest.java
 (original)
+++ 
activemq/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/SplitterWithCustomThreadPoolExecutorTest.java
 Wed Dec 17 05:27:14 2008
@@ -69,7 +69,9 @@
     protected RouteBuilder createRouteBuilder() {
         return new RouteBuilder() {
             public void configure() {
-                
from("direct:parallel-custom-pool").split(body().tokenize(","), true, 
customThreadPoolExecutor).to("mock:result");
+                from("direct:parallel-custom-pool")
+                    .split(body().tokenize(",")).parallelProcessing(true)
+                    .executor(customThreadPoolExecutor).to("mock:result");
             }
         };
     }

Modified: 
activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/LoanBroker.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/LoanBroker.java?rev=727375&r1=727374&r2=727375&view=diff
==============================================================================
--- 
activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/LoanBroker.java
 (original)
+++ 
activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/queue/version/LoanBroker.java
 Wed Dec 17 05:27:14 2008
@@ -100,7 +100,7 @@
             // Set the aggregation strategy for aggregating the out message    
        
             .multicast(new 
BankResponseAggregationStrategy().setAggregatingOutMessage(true))
                 // Send out the request the below three different banks 
parallelly
-                .setParallelProcessing(true).to("jms:queue2:bank1", 
"jms:queue2:bank2", "jms:queue2:bank3");
+                .parallelProcessing(true).to("jms:queue2:bank1", 
"jms:queue2:bank2", "jms:queue2:bank3");
         
         // Each bank processor will process the message and put the response 
message back
         from("jms:queue2:bank1").process(new Bank("bank1"));

Modified: 
activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/webservice/version/LoanBroker.java
URL: 
http://svn.apache.org/viewvc/activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/webservice/version/LoanBroker.java?rev=727375&r1=727374&r2=727375&view=diff
==============================================================================
--- 
activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/webservice/version/LoanBroker.java
 (original)
+++ 
activemq/camel/trunk/examples/camel-example-loan-broker/src/main/java/org/apache/camel/loanbroker/webservice/version/LoanBroker.java
 Wed Dec 17 05:27:14 2008
@@ -96,7 +96,7 @@
                 .multicast(new BankResponseAggregationStrategy())
                     // Camel will create a thread pool with the size of the 
send to endpoints
                     // for sending the message parallelly
-                    .setParallelProcessing(true)
+                    .parallelProcessing(true)
                     .to(Constants.BANK1_URI, Constants.BANK2_URI, 
Constants.BANK3_URI);
 
     //END SNIPPET: dsl


Reply via email to