camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r917530 - in /camel/trunk/components/camel-hawtdb/src: main/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepository.java test/java/org/apache/camel/component/hawtdb/HawtDBAggregateTest.java
Date Mon, 01 Mar 2010 13:58:07 GMT
Author: davsclaus
Date: Mon Mar  1 13:58:07 2010
New Revision: 917530

URL: http://svn.apache.org/viewvc?rev=917530&view=rev
Log:
CAMEL-217: Persistent aggregator. Preserve from endpoint.

Modified:
    camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepository.java
    camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregateTest.java

Modified: camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepository.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepository.java?rev=917530&r1=917529&r2=917530&view=diff
==============================================================================
--- camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepository.java
(original)
+++ camel/trunk/components/camel-hawtdb/src/main/java/org/apache/camel/component/hawtdb/HawtDBAggregationRepository.java
Mon Mar  1 13:58:07 2010
@@ -20,6 +20,7 @@
 import java.io.IOException;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
 import org.apache.camel.Exchange;
 import org.apache.camel.impl.DefaultExchange;
 import org.apache.camel.impl.DefaultExchangeHolder;
@@ -161,6 +162,10 @@
         DefaultExchangeHolder pe = DefaultExchangeHolder.marshal(exchange, false);
         // add the aggregated size property as the only property we want to retain
         DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_SIZE, exchange.getProperty(Exchange.AGGREGATED_SIZE,
Integer.class));
+        // persist the from endpoint as well
+        if (exchange.getFromEndpoint() != null) {
+            DefaultExchangeHolder.addProperty(pe, "CamelAggregatedFromEndpoint", exchange.getFromEndpoint().getEndpointUri());
+        }
         exchangeMarshaller.writePayload(pe, baos);
         return baos.toBuffer();
     }
@@ -170,6 +175,14 @@
         DefaultExchangeHolder pe = exchangeMarshaller.readPayload(bais);
         Exchange answer = new DefaultExchange(camelContext);
         DefaultExchangeHolder.unmarshal(answer, pe);
+        // restore the from endpoint
+        String fromEndpointUri = (String) answer.removeProperty("CamelAggregatedFromEndpoint");
+        if (fromEndpointUri != null) {
+            Endpoint fromEndpoint = camelContext.hasEndpoint(fromEndpointUri);
+            if (fromEndpoint != null) {
+                answer.setFromEndpoint(fromEndpoint);
+            }
+        }
         return answer;
     }
 

Modified: camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregateTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregateTest.java?rev=917530&r1=917529&r2=917530&view=diff
==============================================================================
--- camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregateTest.java
(original)
+++ camel/trunk/components/camel-hawtdb/src/test/java/org/apache/camel/component/hawtdb/HawtDBAggregateTest.java
Mon Mar  1 13:58:07 2010
@@ -43,6 +43,9 @@
         template.sendBodyAndHeader("direct:start", "E", "id", 123);
 
         assertMockEndpointsSatisfied();
+
+        // from endpoint should be preserved
+        assertEquals("direct://start", mock.getReceivedExchanges().get(0).getFromEndpoint().getEndpointUri());
     }
 
     @Override



Mime
View raw message