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 2011/02/09 10:19:03 UTC

svn commit: r1068801 - in /camel/trunk/components/camel-cxf/src: main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerTest.java

Author: ningjiang
Date: Wed Feb  9 09:19:02 2011
New Revision: 1068801

URL: http://svn.apache.org/viewvc?rev=1068801&view=rev
Log:
CAMEL-3643 camel-cxf should not copy the attachments between the CXF and Camel message if the endpoint is working POJO DataFormat

Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
    camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerTest.java

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java?rev=1068801&r1=1068800&r2=1068801&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java (original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java Wed Feb  9 09:19:02 2011
@@ -259,8 +259,9 @@ public class DefaultCxfBinding implement
             camelExchange.getIn().setBody(body);
         }  
         
-        // propagate attachments
-        if (cxfMessage.getAttachments() != null) {
+        // propagate attachments if the data format is not POJO        
+        if (cxfMessage.getAttachments() != null 
+            && !camelExchange.getProperty(CxfConstants.DATA_FORMAT_PROPERTY, DataFormat.class).equals(DataFormat.POJO)) {
             for (Attachment attachment : cxfMessage.getAttachments()) {
                 camelExchange.getIn().addAttachment(attachment.getId(), attachment.getDataHandler());
             }
@@ -337,20 +338,22 @@ public class DefaultCxfBinding implement
             }
         }         
         
-        // propagate attachments
-        Set<Attachment> attachments = null;
-        boolean isXop = Boolean.valueOf(camelExchange.getProperty(Message.MTOM_ENABLED, String.class));
-        for (Map.Entry<String, DataHandler> entry : camelExchange.getOut().getAttachments().entrySet()) {
-            if (attachments == null) {
-                attachments = new HashSet<Attachment>();
-            }
-            AttachmentImpl attachment = new AttachmentImpl(entry.getKey(), entry.getValue());
-            attachment.setXOP(isXop); 
-            attachments.add(attachment);
-        }
-        
-        if (attachments != null) {
-            outMessage.setAttachments(attachments);
+        // propagate attachments if the data format is not POJO
+        if (!DataFormat.POJO.equals(dataFormat)) {
+            Set<Attachment> attachments = null;
+            boolean isXop = Boolean.valueOf(camelExchange.getProperty(Message.MTOM_ENABLED, String.class));
+            for (Map.Entry<String, DataHandler> entry : camelExchange.getOut().getAttachments().entrySet()) {
+                if (attachments == null) {
+                    attachments = new HashSet<Attachment>();
+                }
+                AttachmentImpl attachment = new AttachmentImpl(entry.getKey(), entry.getValue());
+                attachment.setXOP(isXop); 
+                attachments.add(attachment);
+            }
+            
+            if (attachments != null) {
+                outMessage.setAttachments(attachments);
+            }
         }
        
         BindingOperationInfo boi = cxfExchange.get(BindingOperationInfo.class);

Modified: camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerTest.java?rev=1068801&r1=1068800&r2=1068801&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerTest.java (original)
+++ camel/trunk/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerTest.java Wed Feb  9 09:19:02 2011
@@ -53,6 +53,7 @@ public class CxfMtomConsumerTest extends
                     @SuppressWarnings("unchecked")
                     public void process(final Exchange exchange) throws Exception {
                         Message in = exchange.getIn();
+                        assertEquals("We should not get any attachements here.", 0, in.getAttachments().size());
                         // Get the parameter list
                         List<?> parameter = in.getBody(List.class);
                         // Get the operation name
@@ -105,7 +106,7 @@ public class CxfMtomConsumerTest extends
         port.detail(photo, image);
 
         assertEquals("ResponseFromCamel", new String(photo.value, "UTF-8"));
-        assertNotNull(image.value);        
+        assertNotNull(image.value);
         
     }