camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r669101 - in /activemq/camel/trunk/components: camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/ camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/converter/
Date Wed, 18 Jun 2008 07:43:02 GMT
Author: ningjiang
Date: Wed Jun 18 00:43:01 2008
New Revision: 669101

URL: http://svn.apache.org/viewvc?rev=669101&view=rev
Log:
CAMEL-477 added the message converter

Modified:
    activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java
    activemq/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/converter/SpringIntegrationConverter.java

Modified: activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java?rev=669101&r1=669100&r2=669101&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java
(original)
+++ activemq/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/spring/CxfEndpointBeanTest.java
Wed Jun 18 00:43:01 2008
@@ -32,9 +32,7 @@
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-/**
- *
- */
+
 public class CxfEndpointBeanTest extends TestCase {
     private ClassPathXmlApplicationContext ctx;
     protected void setUp() throws Exception {
@@ -65,6 +63,7 @@
                 exchange.getIn().setHeader(CxfConstants.OPERATION_NAME, "echo");
             }
         });
+        
         assertTrue("There should have a timeout exception", exchange.isFailed());
 
     }

Modified: activemq/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/converter/SpringIntegrationConverter.java
URL: http://svn.apache.org/viewvc/activemq/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/converter/SpringIntegrationConverter.java?rev=669101&r1=669100&r2=669101&view=diff
==============================================================================
--- activemq/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/converter/SpringIntegrationConverter.java
(original)
+++ activemq/camel/trunk/components/camel-spring-integration/src/main/java/org/apache/camel/component/spring/integration/converter/SpringIntegrationConverter.java
Wed Jun 18 00:43:01 2008
@@ -16,10 +16,15 @@
  */
 package org.apache.camel.component.spring.integration.converter;
 
+import java.util.Map;
+
 import org.apache.camel.Converter;
 import org.apache.camel.Endpoint;
 import org.apache.camel.component.spring.integration.SpringIntegrationEndpoint;
+import org.apache.camel.component.spring.integration.SpringIntegrationMessage;
 import org.springframework.integration.channel.MessageChannel;
+import org.springframework.integration.message.GenericMessage;
+import org.springframework.integration.message.MessageHeader;
 
 /**
  * The <a href="http://activemq.apache.org/camel/type-converter.html">Type Converters</a>
@@ -49,7 +54,33 @@
         return answer;
     }
 
-    //TODO add the message and endpoint type converter
+
+    @SuppressWarnings("unchecked")
+    @Converter
+    public static org.springframework.integration.message.Message toSpringMessage(final org.apache.camel.Message
camelMessage) throws Exception {
+        if (camelMessage instanceof SpringIntegrationMessage) {
+            SpringIntegrationMessage siMessage = (SpringIntegrationMessage)camelMessage;
+            org.springframework.integration.message.Message message =  siMessage.getMessage();
+            if( message != null) {
+                return message;
+            }
+        }
+
+        // Create a new spring message and copy the attributes and body from the camel message
+        MessageHeader messageHeader = new MessageHeader();
+        Map<String, Object> headers = camelMessage.getHeaders();
+        for(String key : headers.keySet()) {
+            Object value = headers.get(key);
+            messageHeader.setAttribute(key, value);
+        }
+        return new GenericMessage(camelMessage.getBody(), messageHeader);
+    }
+
+    @Converter
+    public static org.apache.camel.Message toCamelMessage(final org.springframework.integration.message.Message
springMessage) throws Exception {
+        return new SpringIntegrationMessage(springMessage);
+    }
+
 
 
 }



Mime
View raw message