camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r791088 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/ main/java/org/apache/camel/impl/ main/java/org/apache/camel/model/ main/java/org/apache/camel/processor/ main/java/org/apache/camel/processor/aggregate/ test/java/org/apa...
Date Sat, 04 Jul 2009 09:34:46 GMT
Author: davsclaus
Date: Sat Jul  4 09:34:44 2009
New Revision: 791088

URL: http://svn.apache.org/viewvc?rev=791088&view=rev
Log:
CAMEL-1078: No there was one more GroupedExchange. And now DefaultExchange is also final.

Removed:
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/GroupedExchange.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/GroupedExchangeAggregationStrategy.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java?rev=791088&r1=791087&r2=791088&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/Exchange.java Sat Jul  4 09:34:44
2009
@@ -66,6 +66,8 @@
     String FILE_PATH            = "CamelFilePath";
     String FILE_PARENT          = "CamelFileParent";
     String FILTERED             = "CamelFiltered";
+
+    String GROUPED_EXCHANGE = "CamelGroupedExchange";
     
     String HTTP_CHARACTER_ENCODING = "CamelHttpCharacterEncoding";
     String HTTP_METHOD             = "CamelHttpMethod";

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java?rev=791088&r1=791087&r2=791088&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/DefaultExchange.java Sat Jul
 4 09:34:44 2009
@@ -38,7 +38,7 @@
  *
  * @version $Revision$
  */
-public class DefaultExchange implements Exchange {
+public final class DefaultExchange implements Exchange {
 
     private static final UuidGenerator DEFAULT_ID_GENERATOR = new UuidGenerator();
     protected final CamelContext context;

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java?rev=791088&r1=791087&r2=791088&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/AggregateDefinition.java Sat
Jul  4 09:34:44 2009
@@ -374,7 +374,8 @@
 
     /**
      * Enables grouped exchanges, so the aggregator will group all aggregated exchanges into
a single
-     * combined {@link org.apache.camel.impl.GroupedExchange} class holding all the aggregated
exchanges.
+     * combined Exchange holding all the aggregated exchanges in a {@link java.util.List}
as a exchange
+     * property with the key {@link org.apache.camel.Exchange#GROUPED_EXCHANGE}.
      *
      * @return the builder
      */

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java?rev=791088&r1=791087&r2=791088&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/BatchProcessor.java Sat
Jul  4 09:34:44 2009
@@ -30,7 +30,7 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Navigate;
 import org.apache.camel.Processor;
-import org.apache.camel.impl.GroupedExchange;
+import org.apache.camel.impl.DefaultExchange;
 import org.apache.camel.impl.LoggingExceptionHandler;
 import org.apache.camel.impl.ServiceSupport;
 import org.apache.camel.spi.ExceptionHandler;
@@ -338,8 +338,9 @@
             }
         }
 
+        @SuppressWarnings("unchecked")
         private void sendExchanges() throws Exception {
-            GroupedExchange grouped = null;
+            Exchange grouped = null;
 
             Iterator<Exchange> iter = collection.iterator();
             while (iter.hasNext()) {
@@ -351,9 +352,14 @@
                 } else {
                     // grouped so add all exchanges into one group
                     if (grouped == null) {
-                        grouped = new GroupedExchange(exchange.getContext());
+                        grouped = new DefaultExchange(exchange);
                     }
-                    grouped.addExchange(exchange);
+                    List<Exchange> list = grouped.getProperty(Exchange.GROUPED_EXCHANGE,
List.class);
+                    if (list == null) {
+                        list = new ArrayList<Exchange>();
+                        grouped.setProperty(Exchange.GROUPED_EXCHANGE, list);
+                    }
+                    list.add(exchange);
                 }
             }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/GroupedExchangeAggregationStrategy.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/GroupedExchangeAggregationStrategy.java?rev=791088&r1=791087&r2=791088&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/GroupedExchangeAggregationStrategy.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/processor/aggregate/GroupedExchangeAggregationStrategy.java
Sat Jul  4 09:34:44 2009
@@ -16,28 +16,37 @@
  */
 package org.apache.camel.processor.aggregate;
 
+import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.camel.Exchange;
-import org.apache.camel.impl.GroupedExchange;
+import org.apache.camel.impl.DefaultExchange;
 
 /**
- * Aggregate all exchanges into a single combined {@link org.apache.camel.impl.GroupedExchange}
holding all
- * the exchanges gathered.
+ * Aggregate all exchanges into a single combined Exchange holding all the aggregated exchanges
+ * in a {@link java.util.List} as a exchange property with the key
+ * {@link org.apache.camel.Exchange#GROUPED_EXCHANGE}.
  *
  * @version $Revision$
  */
 public class GroupedExchangeAggregationStrategy implements AggregationStrategy {
 
+    @SuppressWarnings("unchecked")
     public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
-        GroupedExchange answer;
-        if (!(oldExchange instanceof GroupedExchange)) {
-            answer = new GroupedExchange(oldExchange);
-            answer.addExchange(oldExchange);
+        List<Exchange> list;
+        Exchange answer = oldExchange;
+
+        if (oldExchange == null) {
+            answer = new DefaultExchange(newExchange);
+            list = new ArrayList<Exchange>();
+            answer.setProperty(Exchange.GROUPED_EXCHANGE, list);
         } else {
-            answer = (GroupedExchange) oldExchange;
+            list = oldExchange.getProperty(Exchange.GROUPED_EXCHANGE, List.class);
         }
 
-        answer.addExchange(newExchange);
+        list.add(newExchange);
         return answer;
     }
 
 }
+

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeTest.java?rev=791088&r1=791087&r2=791088&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateGroupedExchangeTest.java
Sat Jul  4 09:34:44 2009
@@ -16,11 +16,12 @@
  */
 package org.apache.camel.processor.aggregator;
 
+import java.util.List;
+
 import org.apache.camel.ContextTestSupport;
 import org.apache.camel.Exchange;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.apache.camel.impl.GroupedExchange;
 
 /**
  * Unit test for aggregate grouped exchanges.
@@ -44,8 +45,8 @@
         assertMockEndpointsSatisfied();
 
         Exchange out = result.getExchanges().get(0);
-        assertTrue(out instanceof GroupedExchange);
-        GroupedExchange grouped = (GroupedExchange)out;
+        List<Exchange> grouped = out.getProperty(Exchange.GROUPED_EXCHANGE, List.class);
+
         assertEquals(5, grouped.size());
 
         assertEquals("100", grouped.get(0).getIn().getBody(String.class));



Mime
View raw message