camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1185156 - in /camel/branches/camel-2.8.x: ./ components/camel-cxf/src/main/java/org/apache/camel/component/cxf/ components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/ components/camel-cxf/src/main/java/org/apache/came...
Date Mon, 17 Oct 2011 13:21:33 GMT
Author: dkulp
Date: Mon Oct 17 13:21:32 2011
New Revision: 1185156

URL: http://svn.apache.org/viewvc?rev=1185156&view=rev
Log:
Merged revisions 1184812,1184814,1184983-1184984,1184987 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk

........
  r1184812 | dkulp | 2011-10-16 08:31:30 -0400 (Sun, 16 Oct 2011) | 5 lines
  
  [CAMEL-4548] Change from using DOM elements to Source objects for the
  internal representation for camel-cxf.   For straight "proxy" use cases
  (from("cxf:...").to("cxf:...)) is allows pure streaming and performance
  improves by over 50% for medium sized (~50K) messages and allows passing
  of massive messages that would previously cause OOM issues.
........
  r1184814 | dkulp | 2011-10-16 08:52:04 -0400 (Sun, 16 Oct 2011) | 1 line
  
  Throw proper exception instead of printing stack trace
........
  r1184983 | dkulp | 2011-10-16 23:04:40 -0400 (Sun, 16 Oct 2011) | 1 line
  
  Restore API compatibility of CxfPayload
........
  r1184984 | dkulp | 2011-10-16 23:04:58 -0400 (Sun, 16 Oct 2011) | 2 lines
  
  Add a flag and system property to control whether streaming is used or
  not.
........
  r1184987 | dkulp | 2011-10-16 23:28:53 -0400 (Sun, 16 Oct 2011) | 2 lines
  
  Use an AbstractList subclass so the returned list is "live" and also
  only un-streams if the appropriate "get" is called.
........

Modified:
    camel/branches/camel-2.8.x/   (props changed)
    camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HybridSourceDataBinding.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayLoadFaultMessageTest.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadTest.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMixedModeRouterTest.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadMessageRouterAddressOverrideTest.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadMessageRouterTest.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadMessageXmlBindingRouterTest.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderTest.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/converter/CxfPayloadConverterTest.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerPayloadModeTest.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomDisabledConsumerPayloadModeTest.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomDisabledProducerPayloadModeTest.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomProducerPayloadModeTest.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest.java
    camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest-context.xml

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Oct 17 13:21:32 2011
@@ -1 +1 @@
-/camel/trunk:1183621
+/camel/trunk:1183621,1184812-1184814,1184983-1184987

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java Mon Oct 17 13:21:32 2011
@@ -24,6 +24,11 @@ import java.util.Map;
 import java.util.concurrent.atomic.AtomicBoolean;
 
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stax.StAXSource;
 import javax.xml.ws.WebServiceProvider;
 import javax.xml.ws.handler.Handler;
 
@@ -80,6 +85,7 @@ import org.apache.cxf.resource.ResourceR
 import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.staxutils.StaxSource;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -105,6 +111,7 @@ public class CxfEndpoint extends Default
     private boolean isWrapped;
     // This is for marshal or unmarshal message with the document-literal wrapped or unwrapped style
     private Boolean wrappedStyle;
+    private Boolean allowStreaming;
     private DataFormat dataFormat = DataFormat.POJO;
     private String publishedEndpointUrl;
     private boolean inOut = true;
@@ -237,7 +244,7 @@ public class CxfEndpoint extends Default
         // apply feature here
         if (!CxfEndpointUtils.hasAnnotation(cls, WebServiceProvider.class)) {
             if (getDataFormat() == DataFormat.PAYLOAD) {
-                sfb.getFeatures().add(new PayLoadDataFormatFeature());
+                sfb.getFeatures().add(new PayLoadDataFormatFeature(allowStreaming));
             } else if (getDataFormat() == DataFormat.MESSAGE) {
                 sfb.getFeatures().add(new MessageDataFormatFeature());
             }
@@ -391,7 +398,7 @@ public class CxfEndpoint extends Default
         if (getDataFormat() == DataFormat.MESSAGE) {
             factoryBean.getFeatures().add(new MessageDataFormatFeature());
         } else if (getDataFormat() == DataFormat.PAYLOAD) {
-            factoryBean.getFeatures().add(new PayLoadDataFormatFeature());
+            factoryBean.getFeatures().add(new PayLoadDataFormatFeature(allowStreaming));
             factoryBean.setDataBinding(new HybridSourceDataBinding());
         }
 
@@ -593,6 +600,13 @@ public class CxfEndpoint extends Default
     public void setWrappedStyle(Boolean wrapped) {
         wrappedStyle = wrapped;
     }
+    
+    public void setAllowStreaming(Boolean b) {
+        allowStreaming = b;
+    }
+    public Boolean getAllowStreaming() {
+        return allowStreaming;
+    }
 
     public void setCxfBinding(CxfBinding cxfBinding) {
         this.cxfBinding = cxfBinding;
@@ -756,16 +770,22 @@ public class CxfEndpoint extends Default
             if (DataFormat.PAYLOAD == message.get(DataFormat.class)) {
 
                 CxfPayload<?> payload = (CxfPayload<?>) params[0];
-                List<Element> elements = payload.getBody();
+                List<Source> elements = payload.getBodySources();
 
                 BindingOperationInfo boi = message.get(BindingOperationInfo.class);
                 MessageContentsList content = new MessageContentsList();
                 int i = 0;
 
                 for (MessagePartInfo partInfo : boi.getInput().getMessageParts()) {
-                    if (elements.size() > i && (isSkipPayloadMessagePartCheck() || partInfo.getConcreteName().getLocalPart().equals(elements.get(i)
-                                                                                                                                            .getLocalName()))) {
-                        content.put(partInfo, elements.get(i++));
+                    if (elements.size() > i) {
+                        if (isSkipPayloadMessagePartCheck()) {
+                            content.put(partInfo, elements.get(i++));
+                        } else {
+                            String name = findName(elements, i);
+                            if (partInfo.getConcreteName().getLocalPart().equals(name)) {
+                                content.put(partInfo, elements.get(i++));
+                            }
+                        }
                     }
                 }
 
@@ -783,6 +803,28 @@ public class CxfEndpoint extends Default
 
             message.remove(DataFormat.class);
         }
+
+        private String findName(List<Source> sources, int i) {
+            Source source = sources.get(i);
+            if (source instanceof DOMSource) {
+                return ((Element)((DOMSource)source).getNode()).getLocalName();
+            } else if (source instanceof StaxSource) {
+                StaxSource s = (StaxSource)source;
+                return s.getXMLStreamReader().getLocalName();
+            } else if (source instanceof StAXSource) {
+                StAXSource s = (StAXSource)source;
+                XMLStreamReader r = s.getXMLStreamReader();
+                if (r.getEventType() != XMLStreamReader.START_ELEMENT) {
+                    try {
+                        r.nextTag();
+                    } catch (XMLStreamException e) {
+                        //ignore
+                    }
+                }
+                return r.getLocalName();
+            }
+            return null;
+        }
     }
     
 

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfPayload.java Mon Oct 17 13:21:32 2011
@@ -16,11 +16,23 @@
  */
 package org.apache.camel.component.cxf;
 
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
+import javax.xml.XMLConstants;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.transform.Source;
 import javax.xml.transform.TransformerException;
+import javax.xml.transform.dom.DOMSource;
+
 import org.w3c.dom.Element;
+
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.converter.jaxp.XmlConverter;
+import org.apache.cxf.staxutils.StaxUtils;
 
 
 /**
@@ -30,15 +42,87 @@ import org.apache.camel.converter.jaxp.X
  */
 public class CxfPayload<T> {
     
-    private List<Element> body;
+    private List<Source> body;
     private List<T> headers;
-
-    public CxfPayload(List<T> headers, List<Element> body) {
+    private Map<String, String> nsMap;
+    
+    public CxfPayload(List<T> headers, List<Source> body, Map<String, String> nsMap) {
         this.headers = headers;
         this.body = body;
+        this.nsMap = nsMap;
     }
+    public CxfPayload(List<T> headers, List<Element> body) {
+        this.headers = headers;
+        this.body = new ArrayList<Source>(body.size());
+        for (Element el : body) {
+            this.body.add(new DOMSource(el));
+        }
+    } 
     
+    /**
+     * Get the body as a List of DOM elements. 
+     * This will cause the Body to be fully read and parsed.
+     * @return
+     */
     public List<Element> getBody() {
+        return new AbstractList<Element>() {
+            public boolean add(Element e) {
+                return body.add(new DOMSource(e));
+            }
+
+            public Element set(int index, Element element) {
+                Source s = body.set(index, new DOMSource(element));
+                try {
+                    return StaxUtils.read(s).getDocumentElement();
+                } catch (XMLStreamException e) {
+                    throw new RuntimeCamelException("Problem converting content to Element", e);
+                }
+            }
+
+            public void add(int index, Element element) {
+                body.add(index, new DOMSource(element));
+            }
+
+            public Element remove(int index) {
+                Source s = body.remove(index);
+                try {
+                    return StaxUtils.read(s).getDocumentElement();
+                } catch (XMLStreamException e) {
+                    throw new RuntimeCamelException("Problem converting content to Element", e);
+                }
+            }
+
+            public Element get(int index) {
+                Source s = body.get(index);
+                try {
+                    Element el = StaxUtils.read(s).getDocumentElement();
+                    addNamespace(el, nsMap);
+                    body.set(index, new DOMSource(el));
+                    return el;
+                } catch (Exception ex) {
+                    throw new RuntimeCamelException("Problem converting content to Element", ex);
+                }
+            }
+
+            public int size() {
+                return body.size();
+            }
+        };
+    }
+    
+    protected static void addNamespace(Element element, Map<String, String> nsMap) {
+        if (nsMap != null) {
+            for (String ns : nsMap.keySet()) {
+                element.setAttribute(XMLConstants.XMLNS_ATTRIBUTE + ":" + ns, nsMap.get(ns));
+            }
+        }
+    }
+
+    /**
+     * Gets the body as a List of source objects
+     * @return
+     */
+    public List<Source> getBodySources() {
         return body;
     }
     
@@ -56,12 +140,12 @@ public class CxfPayload<T> {
             buf.append("body: " + body);
         } else {
             buf.append("body: [ ");
-            for (Element element : body) {
+            for (Element src : getBody()) {
                 String elementString = "";
                 try {
-                    elementString = converter.toString(element, null);
+                    elementString = converter.toString(src, null);
                 } catch (TransformerException e) {
-                    elementString = element.toString();
+                    elementString = src.toString();
                 }
                 buf.append("[" + elementString + "]");
             }

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/DefaultCxfBinding.java Mon Oct 17 13:21:32 2011
@@ -315,7 +315,7 @@ public class DefaultCxfBinding implement
         if (outBody != null) {
             if (dataFormat == DataFormat.PAYLOAD) {
                 CxfPayload<?> payload = (CxfPayload<?>)outBody;
-                outMessage.setContent(List.class, getResponsePayloadList(cxfExchange, payload.getBody()));
+                outMessage.setContent(List.class, getResponsePayloadList(cxfExchange, payload.getBodySources()));
                 outMessage.put(Header.HEADER_LIST, payload.getHeaders());
             } else {
                 if (responseContext.get(Header.HEADER_LIST) != null) {
@@ -379,7 +379,7 @@ public class DefaultCxfBinding implement
     // -------------------------------------------------------------------------
     
     protected MessageContentsList getResponsePayloadList(org.apache.cxf.message.Exchange exchange, 
-                                                         List<Element> elements) {
+                                                         List<Source> elements) {
         BindingOperationInfo boi = exchange.getBindingOperationInfo();
 
         if (boi.isUnwrapped()) {
@@ -612,7 +612,8 @@ public class DefaultCxfBinding implement
                 }
             } else if (dataFormat == DataFormat.PAYLOAD) {
                 List<SoapHeader> headers = CastUtils.cast((List<?>)message.get(Header.HEADER_LIST));
-                answer = new CxfPayload<SoapHeader>(headers, getPayloadBodyElements(message));
+                Map<String, String> nsMap = new HashMap<String, String>();
+                answer = new CxfPayload<SoapHeader>(headers, getPayloadBodyElements(message, nsMap), nsMap);
                 
             } else if (dataFormat == DataFormat.MESSAGE) {
                 answer = message.getContent(InputStream.class);
@@ -630,10 +631,9 @@ public class DefaultCxfBinding implement
                      
     }
 
-    protected static List<Element> getPayloadBodyElements(Message message) {
+    protected static List<Source> getPayloadBodyElements(Message message, Map<String, String> nsMap) {
         // take the namespace attribute from soap envelop
         Document soapEnv = (Document) message.getContent(Node.class);
-        Map<String, String> nsMap = new HashMap<String, String>();
         if (soapEnv != null) {
             NamedNodeMap attrs = soapEnv.getFirstChild().getAttributes();
             for (int i = 0; i < attrs.getLength(); i++) {
@@ -668,7 +668,7 @@ public class DefaultCxfBinding implement
             partInfos = op.getInput().getMessageParts();            
         }
         
-        List<Element> answer = new ArrayList<Element>();
+        List<Source> answer = new ArrayList<Source>();
 
         for (MessagePartInfo partInfo : partInfos) {
             if (!inObjects.hasValue(partInfo)) {
@@ -682,16 +682,16 @@ public class DefaultCxfBinding implement
             }
                         
             if (part instanceof Source) {
-                Element element;
+                Element element = null;
                 if (part instanceof DOMSource) {
                     element = getFirstElement(((DOMSource)part).getNode());
-                } else {
-                    element = getFirstElement((Source)part);
                 }
 
                 if (element != null) {
                     addNamespace(element, nsMap);
-                    answer.add(element);
+                    answer.add(new DOMSource(element));
+                } else {
+                    answer.add((Source)part);
                 }
                 
                 if (LOG.isTraceEnabled()) {
@@ -700,7 +700,7 @@ public class DefaultCxfBinding implement
                 }
             } else if (part instanceof Element) {
                 addNamespace((Element)part, nsMap);
-                answer.add((Element)part);
+                answer.add(new DOMSource((Element)part));
             } else {
                 if (LOG.isDebugEnabled()) {
                     LOG.debug("Unhandled part type '{}'", part.getClass());
@@ -733,14 +733,6 @@ public class DefaultCxfBinding implement
         return DOMUtils.getFirstElement(node);
     }
     
-    private static Element getFirstElement(Source source) {
-        try {
-            return ((Document)XMLUtils.fromSource(source)).getDocumentElement();
-        } catch (Exception e) {
-            // ignore
-        }
-        return null;
-    }
     
     public void copyJaxWsContext(org.apache.cxf.message.Exchange cxfExchange, Map<String, Object> context) {
         if (cxfExchange.getOutMessage() != null) {

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HybridSourceDataBinding.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HybridSourceDataBinding.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HybridSourceDataBinding.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/HybridSourceDataBinding.java Mon Oct 17 13:21:32 2011
@@ -16,18 +16,30 @@
  */
 package org.apache.camel.component.cxf;
 
+import java.util.logging.Logger;
+
+import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
+import javax.xml.transform.Source;
+import javax.xml.transform.stax.StAXSource;
 
 import org.w3c.dom.Node;
 
+import org.apache.cxf.common.i18n.Message;
+import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.databinding.DataReader;
 import org.apache.cxf.databinding.DataWriter;
 import org.apache.cxf.databinding.source.NodeDataReader;
 import org.apache.cxf.databinding.source.NodeDataWriter;
+import org.apache.cxf.databinding.source.SourceDataBinding;
 import org.apache.cxf.databinding.source.XMLStreamDataReader;
 import org.apache.cxf.databinding.source.XMLStreamDataWriter;
+import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.jaxb.JAXBDataBinding;
+import org.apache.cxf.service.model.MessagePartInfo;
+import org.apache.cxf.staxutils.StaxSource;
+import org.apache.cxf.staxutils.StaxUtils;
 
 
 /**
@@ -40,6 +52,8 @@ import org.apache.cxf.jaxb.JAXBDataBindi
  * @version @Revision: 789534 $
  */
 public class HybridSourceDataBinding extends JAXBDataBinding {
+    private static final Logger LOG = LogUtils.getL7dLogger(SourceDataBinding.class);
+    
     public HybridSourceDataBinding() {
         super();
     }
@@ -65,7 +79,27 @@ public class HybridSourceDataBinding ext
     @Override
     public <T> DataWriter<T> createWriter(Class<T> cls) {
         if (cls == XMLStreamWriter.class) {
-            return (DataWriter<T>) new XMLStreamDataWriter();
+            return (DataWriter<T>) new XMLStreamDataWriter() {
+
+                public void write(Object obj, MessagePartInfo part, XMLStreamWriter output) {
+                    if (obj == null) {
+                        return;
+                    }
+                    if (obj instanceof StaxSource
+                        || obj instanceof StAXSource) {
+                        XMLStreamReader reader = StaxUtils.createXMLStreamReader((Source)obj);
+                        try {
+                            StaxUtils.copy(reader, output);
+                            reader.close();
+                        } catch (XMLStreamException e) {
+                            throw new Fault(new Message("COULD_NOT_READ_XML_STREAM", LOG), e);
+                        }
+                        return;
+                    }
+                    super.write(obj, part, output);
+                }
+                
+            };
         } else if (cls == Node.class) {
             return (DataWriter<T>) new NodeDataWriter();
         } else {

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java Mon Oct 17 13:21:32 2011
@@ -19,6 +19,11 @@ package org.apache.camel.component.cxf.c
 import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
+
+import javax.xml.stream.XMLStreamException;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -27,9 +32,11 @@ import org.w3c.dom.NodeList;
 import org.apache.camel.Converter;
 import org.apache.camel.Exchange;
 import org.apache.camel.FallbackConverter;
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.TypeConverter;
 import org.apache.camel.component.cxf.CxfPayload;
 import org.apache.camel.spi.TypeConverterRegistry;
+import org.apache.cxf.staxutils.StaxUtils;
 
 @Converter
 public final class CxfPayloadConverter {
@@ -73,6 +80,7 @@ public final class CxfPayloadConverter {
     @Converter
     public static <T> Node cxfPayLoadToNode(CxfPayload<T> payload, Exchange exchange) {
         List<Element> payloadBodyElements = payload.getBody();
+        
         if (payloadBodyElements.size() > 0) {
             return payloadBodyElements.get(0);
         }

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/AbstractDataFormatFeature.java Mon Oct 17 13:21:32 2011
@@ -75,4 +75,13 @@ public abstract class AbstractDataFormat
             }
         }
     }
+    
+    protected void removeInterceptor(List<Interceptor<? extends Message>> interceptors, 
+                                     Class<? extends Interceptor> cls) {
+        for (Interceptor interceptor : interceptors) {
+            if (interceptor.getClass().equals(cls)) {
+                interceptors.remove(interceptor);
+            }
+        }        
+    }
 }

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/feature/PayLoadDataFormatFeature.java Mon Oct 17 13:21:32 2011
@@ -18,15 +18,21 @@ package org.apache.camel.component.cxf.f
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
 
 import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
 
 import org.apache.camel.component.cxf.interceptors.ConfigureDocLitWrapperInterceptor;
 import org.apache.cxf.Bus;
 import org.apache.cxf.binding.Binding;
+import org.apache.cxf.binding.soap.interceptor.SoapHeaderInterceptor;
 import org.apache.cxf.endpoint.Client;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.interceptor.ClientFaultConverter;
+import org.apache.cxf.jaxws.interceptors.HolderInInterceptor;
+import org.apache.cxf.jaxws.interceptors.HolderOutInterceptor;
 import org.apache.cxf.service.model.BindingMessageInfo;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.MessageInfo;
@@ -41,15 +47,34 @@ import org.slf4j.LoggerFactory;
 public class PayLoadDataFormatFeature extends AbstractDataFormatFeature {
     private static final Logger LOG = LoggerFactory.getLogger(PayLoadDataFormatFeature.class);
     private static final Collection<Class> REMOVING_FAULT_IN_INTERCEPTORS;
-
+    private static final boolean DEFAULT_ALLOW_STREAMING;
     static {
         REMOVING_FAULT_IN_INTERCEPTORS = new ArrayList<Class>();
         REMOVING_FAULT_IN_INTERCEPTORS.add(ClientFaultConverter.class);
+        
+        String s = System.getProperty("org.apache.camel.component.cxf.streaming");
+        DEFAULT_ALLOW_STREAMING = s == null || Boolean.parseBoolean(s);
     }
 
+    boolean allowStreaming = DEFAULT_ALLOW_STREAMING;
+    
+    public PayLoadDataFormatFeature() {
+    }
+    public PayLoadDataFormatFeature(Boolean streaming) {
+        if (streaming != null) {
+            allowStreaming = streaming;
+        }
+    }
+    
+    
     @Override
     public void initialize(Client client, Bus bus) {
         removeFaultInInterceptorFromClient(client);
+        
+        removeInterceptor(client.getEndpoint().getInInterceptors(), 
+                          HolderInInterceptor.class);
+        removeInterceptor(client.getEndpoint().getBinding().getInInterceptors(), 
+                          SoapHeaderInterceptor.class);
         client.getEndpoint().getBinding().getInInterceptors().add(new ConfigureDocLitWrapperInterceptor(true));
         resetPartTypes(client.getEndpoint().getBinding());
     }
@@ -58,6 +83,12 @@ public class PayLoadDataFormatFeature ex
     @Override
     public void initialize(Server server, Bus bus) {
         server.getEndpoint().getBinding().getInInterceptors().add(new ConfigureDocLitWrapperInterceptor(true));
+        removeInterceptor(server.getEndpoint().getInInterceptors(), 
+                          HolderInInterceptor.class);
+        removeInterceptor(server.getEndpoint().getOutInterceptors(), 
+                          HolderOutInterceptor.class);
+        removeInterceptor(server.getEndpoint().getBinding().getInInterceptors(), 
+                          SoapHeaderInterceptor.class);
         resetPartTypes(server.getEndpoint().getBinding());
     }
 
@@ -91,16 +122,28 @@ public class PayLoadDataFormatFeature ex
     
     protected void resetPartTypeClass(BindingMessageInfo bmi) {
         if (bmi != null) {
-            for (MessagePartInfo part : bmi.getMessageParts()) {
-                part.setTypeClass(null);
-            }     
+            int size = bmi.getMessageParts().size();
+            for (int x = 0; x < size; x++) {
+                //last part can be streamed, others need DOM parsing 
+                if (x < (size - 1)) {
+                    bmi.getMessageParts().get(x).setTypeClass(allowStreaming ? DOMSource.class : null);
+                } else {
+                    bmi.getMessageParts().get(x).setTypeClass(allowStreaming ? Source.class : null);
+                }
+            }
         }
     }
     protected void resetPartTypeClass(MessageInfo msgInfo) {
         if (msgInfo != null) {
-            for (MessagePartInfo part : msgInfo.getMessageParts()) {
-                part.setTypeClass(null);
-            }     
+            int size = msgInfo.getMessageParts().size();
+            for (int x = 0; x < size; x++) {
+                //last part can be streamed, others need DOM parsing 
+                if (x < (size - 1)) {
+                    msgInfo.getMessageParts().get(x).setTypeClass(allowStreaming ? DOMSource.class : null);
+                } else {
+                    msgInfo.getMessageParts().get(x).setTypeClass(allowStreaming ? Source.class : null);
+                }
+            }
         }
     }
     private void removeFaultInInterceptorFromClient(Client client) {

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayLoadFaultMessageTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayLoadFaultMessageTest.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayLoadFaultMessageTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayLoadFaultMessageTest.java Mon Oct 17 13:21:32 2011
@@ -20,6 +20,9 @@ import java.io.StringReader;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+
 import org.w3c.dom.Element;
 
 import org.apache.camel.Exchange;

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadTest.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfConsumerPayloadTest.java Mon Oct 17 13:21:32 2011
@@ -18,6 +18,10 @@ package org.apache.camel.component.cxf;
 
 import java.util.ArrayList;
 import java.util.List;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.apache.camel.Exchange;
@@ -58,18 +62,19 @@ public class CxfConsumerPayloadTest exte
                     @SuppressWarnings("unchecked")
                     public void process(final Exchange exchange) throws Exception {
                         CxfPayload<SoapHeader> requestPayload = exchange.getIn().getBody(CxfPayload.class);
-                        List<Element> inElements = requestPayload.getBody();
-                        List<Element> outElements = new ArrayList<Element>();
+                        List<Source> inElements = requestPayload.getBodySources();
+                        List<Source> outElements = new ArrayList<Source>();
                         // You can use a customer toStringConverter to turn a CxfPayLoad message into String as you want                        
                         String request = exchange.getIn().getBody(String.class);
                         XmlConverter converter = new XmlConverter();
                         String documentString = ECHO_RESPONSE;
                         
+                        Element in = new XmlConverter().toDOMElement(inElements.get(0));
                         // Just check the element namespace
-                        if (!inElements.get(0).getNamespaceURI().equals(ELEMENT_NAMESPACE)) {
+                        if (!in.getNamespaceURI().equals(ELEMENT_NAMESPACE)) {
                             throw new IllegalArgumentException("Wrong element namespace");
                         }
-                        if (inElements.get(0).getLocalName().equals("echoBoolean")) {
+                        if (in.getLocalName().equals("echoBoolean")) {
                             documentString = ECHO_BOOLEAN_RESPONSE;
                             checkRequest("ECHO_BOOLEAN_REQUEST", request);
                         } else {
@@ -77,9 +82,9 @@ public class CxfConsumerPayloadTest exte
                             checkRequest("ECHO_REQUEST", request);
                         }
                         Document outDocument = converter.toDOMDocument(documentString);
-                        outElements.add(outDocument.getDocumentElement());
+                        outElements.add(new DOMSource(outDocument.getDocumentElement()));
                         // set the payload header with null
-                        CxfPayload<SoapHeader> responsePayload = new CxfPayload<SoapHeader>(null, outElements);
+                        CxfPayload<SoapHeader> responsePayload = new CxfPayload<SoapHeader>(null, outElements, null);
                         exchange.getOut().setBody(responsePayload); 
                     }
                 });

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMixedModeRouterTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMixedModeRouterTest.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMixedModeRouterTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfMixedModeRouterTest.java Mon Oct 17 13:21:32 2011
@@ -20,6 +20,9 @@ package org.apache.camel.component.cxf;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+
 import org.w3c.dom.Element;
 
 import org.apache.camel.CamelContext;
@@ -27,6 +30,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.cxf.common.message.CxfConstants;
+import org.apache.camel.converter.jaxp.XmlConverter;
 import org.apache.camel.impl.DefaultCamelContext;
 import org.apache.camel.test.AvailablePortFinder;
 import org.apache.camel.test.junit4.CamelTestSupport;
@@ -88,7 +92,7 @@ public class CxfMixedModeRouterTest exte
 
                         if (message != null) {
                             // convert CxfPayload to list of objects any way you like
-                            Element element = message.getBody().get(0);
+                            Element element = new XmlConverter().toDOMElement(message.getBody().get(0));
                             params.add(element.getFirstChild().getTextContent());
                         }
                             

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadMessageRouterAddressOverrideTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadMessageRouterAddressOverrideTest.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadMessageRouterAddressOverrideTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadMessageRouterAddressOverrideTest.java Mon Oct 17 13:21:32 2011
@@ -17,10 +17,14 @@
 package org.apache.camel.component.cxf;
 
 import java.util.List;
+
+import javax.xml.transform.Source;
+
 import org.w3c.dom.Element;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.converter.jaxp.XmlConverter;
 
 
 /**
@@ -41,10 +45,11 @@ public class CxfPayLoadMessageRouterAddr
                         exchange.getIn().setHeader(Exchange.DESTINATION_OVERRIDE_URL, SERVICE_ADDRESS);
                         
                         CxfPayload<?> payload = exchange.getIn().getBody(CxfPayload.class);
-                        List<Element> elements = payload.getBody();
+                        List<Source> elements = payload.getBodySources();
                         assertNotNull("We should get the elements here" , elements);
                         assertEquals("Get the wrong elements size" , elements.size(), 1);
-                        assertEquals("Get the wrong namespace URI" , elements.get(0).getNamespaceURI(), "http://cxf.component.camel.apache.org/");
+                        Element el = new XmlConverter().toDOMElement(elements.get(0));
+                        assertEquals("Get the wrong namespace URI" , el.getNamespaceURI(), "http://cxf.component.camel.apache.org/");
                     }
                     
                 })

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadMessageRouterTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadMessageRouterTest.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadMessageRouterTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadMessageRouterTest.java Mon Oct 17 13:21:32 2011
@@ -18,11 +18,14 @@ package org.apache.camel.component.cxf;
 
 import java.util.List;
 
+import javax.xml.transform.Source;
+
 import org.w3c.dom.Element;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.converter.jaxp.XmlConverter;
 
 
 /**
@@ -40,10 +43,11 @@ public class CxfPayLoadMessageRouterTest
                 from(routerEndpointURI).process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         CxfPayload<?> payload = exchange.getIn().getBody(CxfPayload.class);
-                        List<Element> elements = payload.getBody();
+                        List<Source> elements = payload.getBodySources();
                         assertNotNull("We should get the elements here" , elements);
                         assertEquals("Get the wrong elements size" , elements.size(), 1);
-                        assertEquals("Get the wrong namespace URI" , elements.get(0).getNamespaceURI(), "http://cxf.component.camel.apache.org/");
+                        Element el = new XmlConverter().toDOMElement(elements.get(0));
+                        assertEquals("Get the wrong namespace URI" , el.getNamespaceURI(), "http://cxf.component.camel.apache.org/");
                     }
                     
                 })

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadMessageXmlBindingRouterTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadMessageXmlBindingRouterTest.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadMessageXmlBindingRouterTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadMessageXmlBindingRouterTest.java Mon Oct 17 13:21:32 2011
@@ -18,12 +18,15 @@ package org.apache.camel.component.cxf;
 
 import java.util.List;
 
+import javax.xml.transform.Source;
+
 import org.w3c.dom.Element;
 
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.converter.jaxp.XmlConverter;
 import org.apache.camel.spring.SpringCamelContext;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.apache.cxf.endpoint.Server;
@@ -106,10 +109,12 @@ public class CxfPayLoadMessageXmlBinding
                 from("cxf:bean:routerEndpoint?dataFormat=PAYLOAD").process(new Processor() {
                     public void process(Exchange exchange) throws Exception {
                         CxfPayload<?> payload = exchange.getIn().getBody(CxfPayload.class);
-                        List<Element> elements = payload.getBody();
+                        List<Source> elements = payload.getBodySources();
                         assertNotNull("We should get the elements here" , elements);
                         assertEquals("Get the wrong elements size" , elements.size(), 1);
-                        assertEquals("Get the wrong namespace URI" , elements.get(0).getNamespaceURI(), "http://cxf.component.camel.apache.org/");
+                        
+                        Element el = new XmlConverter().toDOMElement(elements.get(0));
+                        assertEquals("Get the wrong namespace URI" , el.getNamespaceURI(), "http://cxf.component.camel.apache.org/");
                     }
                     
                 })

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderTest.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/CxfPayLoadSoapHeaderTest.java Mon Oct 17 13:21:32 2011
@@ -20,6 +20,9 @@ import java.net.URL;
 import java.util.List;
 
 import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Endpoint;
 
 import org.w3c.dom.Element;
@@ -27,6 +30,7 @@ import org.w3c.dom.Element;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.converter.jaxp.XmlConverter;
 import org.apache.camel.pizza.Pizza;
 import org.apache.camel.pizza.PizzaService;
 import org.apache.camel.pizza.types.CallerIDHeaderType;
@@ -59,11 +63,14 @@ public class CxfPayLoadSoapHeaderTest ex
                     @SuppressWarnings("unchecked")
                     public void process(Exchange exchange) throws Exception {
                         CxfPayload<SoapHeader> payload = exchange.getIn().getBody(CxfPayload.class);
-                        List<Element> elements = payload.getBody();
+                        List<Source> elements = payload.getBodySources();
                         assertNotNull("We should get the elements here", elements);
                         assertEquals("Get the wrong elements size", 1, elements.size());
+                        
+                        Element el = new XmlConverter().toDOMElement(elements.get(0));
+                        elements.set(0, new DOMSource(el));
                         assertEquals("Get the wrong namespace URI", "http://camel.apache.org/pizza/types", 
-                                elements.get(0).getNamespaceURI());
+                                el.getNamespaceURI());
                             
                         List<SoapHeader> headers = payload.getHeaders();
                         assertNotNull("We should get the headers here", headers);

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/converter/CxfPayloadConverterTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/converter/CxfPayloadConverterTest.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/converter/CxfPayloadConverterTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/converter/CxfPayloadConverterTest.java Mon Oct 17 13:21:32 2011
@@ -24,6 +24,8 @@ import java.util.List;
 
 import javax.xml.parsers.DocumentBuilder;
 import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
 
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -52,10 +54,10 @@ public class CxfPayloadConverterTest ext
         DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
         document = documentBuilder.parse(file);
         document.getDocumentElement().normalize();
-        List<Element> body = new ArrayList<Element>();
-        body.add(document.getDocumentElement());
-        payload = new CxfPayload<String[]>(new ArrayList<String[]>(), body);
-        emptyPayload = new CxfPayload<String[]>(new ArrayList<String[]>(), new ArrayList<Element>());
+        List<Source> body = new ArrayList<Source>();
+        body.add(new DOMSource(document.getDocumentElement()));
+        payload = new CxfPayload<String[]>(new ArrayList<String[]>(), body, null);
+        emptyPayload = new CxfPayload<String[]>(new ArrayList<String[]>(), new ArrayList<Source>(), null);
         inputStream = new FileInputStream(file);
     }
 

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerPayloadModeTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerPayloadModeTest.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerPayloadModeTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomConsumerPayloadModeTest.java Mon Oct 17 13:21:32 2011
@@ -24,6 +24,8 @@ import java.util.Map;
 
 import javax.activation.DataHandler;
 import javax.mail.util.ByteArrayDataSource;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
 import javax.xml.xpath.XPathConstants;
 
 import org.w3c.dom.Element;
@@ -35,6 +37,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Processor;
 import org.apache.camel.component.cxf.CxfPayload;
+import org.apache.camel.converter.jaxp.XmlConverter;
 import org.apache.cxf.binding.soap.SoapHeader;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.IOUtils;
@@ -65,10 +68,10 @@ public class CxfMtomConsumerPayloadModeT
             public void process(Exchange exchange) throws Exception {
                 exchange.setPattern(ExchangePattern.InOut);
                 assertEquals("Get a wrong Content-Type header", "application/xop+xml", exchange.getIn().getHeader("Content-Type"));
-                List<Element> elements = new ArrayList<Element>();
-                elements.add(DOMUtils.readXml(new StringReader(getRequestMessage())).getDocumentElement());
+                List<Source> elements = new ArrayList<Source>();
+                elements.add(new DOMSource(DOMUtils.readXml(new StringReader(getRequestMessage())).getDocumentElement()));
                 CxfPayload<SoapHeader> body = new CxfPayload<SoapHeader>(new ArrayList<SoapHeader>(),
-                    elements);
+                    elements, null);
                 exchange.getIn().setBody(body);
                 exchange.getIn().addAttachment(MtomTestHelper.REQ_PHOTO_CID, 
                     new DataHandler(new ByteArrayDataSource(MtomTestHelper.REQ_PHOTO_DATA, "application/octet-stream")));
@@ -94,12 +97,13 @@ public class CxfMtomConsumerPayloadModeT
             ns.put("xop", MtomTestHelper.XOP_NS);
 
             XPathUtils xu = new XPathUtils(ns);
-            Element ele = (Element)xu.getValue("//ns:Detail/ns:photo/xop:Include", in.getBody().get(0),
+            Element body = new XmlConverter().toDOMElement(in.getBody().get(0));
+            Element ele = (Element)xu.getValue("//ns:Detail/ns:photo/xop:Include", body,
                                                XPathConstants.NODE);
             String photoId = ele.getAttribute("href").substring(4); // skip "cid:"
             Assert.assertEquals(MtomTestHelper.REQ_PHOTO_CID, photoId);
 
-            ele = (Element)xu.getValue("//ns:Detail/ns:image/xop:Include", in.getBody().get(0),
+            ele = (Element)xu.getValue("//ns:Detail/ns:image/xop:Include", body,
                                                XPathConstants.NODE);
             String imageId = ele.getAttribute("href").substring(4); // skip "cid:"
             Assert.assertEquals(MtomTestHelper.REQ_IMAGE_CID, imageId);
@@ -113,11 +117,11 @@ public class CxfMtomConsumerPayloadModeT
             MtomTestHelper.assertEquals(MtomTestHelper.requestJpeg, IOUtils.readBytesFromStream(dr.getInputStream()));
 
             // create response
-            List<Element> elements = new ArrayList<Element>();
-            elements.add(DOMUtils.readXml(new StringReader(MtomTestHelper.RESP_MESSAGE)).getDocumentElement());
-            CxfPayload<SoapHeader> body = new CxfPayload<SoapHeader>(new ArrayList<SoapHeader>(),
-                elements);
-            exchange.getOut().setBody(body);
+            List<Source> elements = new ArrayList<Source>();
+            elements.add(new DOMSource(DOMUtils.readXml(new StringReader(MtomTestHelper.RESP_MESSAGE)).getDocumentElement()));
+            CxfPayload<SoapHeader> sbody = new CxfPayload<SoapHeader>(new ArrayList<SoapHeader>(),
+                elements, null);
+            exchange.getOut().setBody(sbody);
             exchange.getOut().addAttachment(MtomTestHelper.RESP_PHOTO_CID, 
                 new DataHandler(new ByteArrayDataSource(MtomTestHelper.RESP_PHOTO_DATA, "application/octet-stream")));
 

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomDisabledConsumerPayloadModeTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomDisabledConsumerPayloadModeTest.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomDisabledConsumerPayloadModeTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomDisabledConsumerPayloadModeTest.java Mon Oct 17 13:21:32 2011
@@ -22,6 +22,8 @@ import java.util.List;
 
 import javax.activation.DataHandler;
 import javax.mail.util.ByteArrayDataSource;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
 
 import org.w3c.dom.Element;
 
@@ -68,10 +70,10 @@ public class CxfMtomDisabledConsumerPayl
             MtomTestHelper.assertEquals(MtomTestHelper.requestJpeg, IOUtils.readBytesFromStream(dr.getInputStream()));
 
             // create response
-            List<Element> elements = new ArrayList<Element>();
-            elements.add(DOMUtils.readXml(new StringReader(MtomTestHelper.MTOM_DISABLED_RESP_MESSAGE)).getDocumentElement());
+            List<Source> elements = new ArrayList<Source>();
+            elements.add(new DOMSource(DOMUtils.readXml(new StringReader(MtomTestHelper.MTOM_DISABLED_RESP_MESSAGE)).getDocumentElement()));
             CxfPayload<SoapHeader> body = new CxfPayload<SoapHeader>(new ArrayList<SoapHeader>(),
-                elements);
+                elements, null);
             exchange.getOut().setBody(body);
             exchange.getOut().addAttachment(MtomTestHelper.RESP_PHOTO_CID, 
                 new DataHandler(new ByteArrayDataSource(MtomTestHelper.RESP_PHOTO_DATA, "application/octet-stream")));

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomDisabledProducerPayloadModeTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomDisabledProducerPayloadModeTest.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomDisabledProducerPayloadModeTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomDisabledProducerPayloadModeTest.java Mon Oct 17 13:21:32 2011
@@ -30,6 +30,8 @@ import javax.activation.DataSource;
 import javax.annotation.Resource;
 import javax.imageio.ImageIO;
 import javax.mail.util.ByteArrayDataSource;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
 import javax.xml.ws.Holder;
 import javax.xml.ws.WebServiceContext;
 import javax.xml.ws.handler.MessageContext;
@@ -82,10 +84,10 @@ public class CxfMtomDisabledProducerPayl
 
             public void process(Exchange exchange) throws Exception {
                 exchange.setPattern(ExchangePattern.InOut);
-                List<Element> elements = new ArrayList<Element>();
-                elements.add(DOMUtils.readXml(new StringReader(MtomTestHelper.MTOM_DISABLED_REQ_MESSAGE)).getDocumentElement());
+                List<Source> elements = new ArrayList<Source>();
+                elements.add(new DOMSource(DOMUtils.readXml(new StringReader(MtomTestHelper.MTOM_DISABLED_REQ_MESSAGE)).getDocumentElement()));
                 CxfPayload<SoapHeader> body = new CxfPayload<SoapHeader>(new ArrayList<SoapHeader>(),
-                    elements);
+                    elements, null);
                 exchange.getIn().setBody(body);
                 exchange.getIn().addAttachment(MtomTestHelper.REQ_PHOTO_CID, 
                     new DataHandler(new ByteArrayDataSource(MtomTestHelper.REQ_PHOTO_DATA, "application/octet-stream")));

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomProducerPayloadModeTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomProducerPayloadModeTest.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomProducerPayloadModeTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/mtom/CxfMtomProducerPayloadModeTest.java Mon Oct 17 13:21:32 2011
@@ -26,6 +26,8 @@ import java.util.Map;
 import javax.activation.DataHandler;
 import javax.imageio.ImageIO;
 import javax.mail.util.ByteArrayDataSource;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
 import javax.xml.ws.Endpoint;
 import javax.xml.ws.soap.SOAPBinding;
 import javax.xml.xpath.XPathConstants;
@@ -37,6 +39,7 @@ import org.apache.camel.Exchange;
 import org.apache.camel.ExchangePattern;
 import org.apache.camel.Processor;
 import org.apache.camel.component.cxf.CxfPayload;
+import org.apache.camel.converter.jaxp.XmlConverter;
 import org.apache.cxf.binding.soap.SoapHeader;
 import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.IOUtils;
@@ -91,10 +94,10 @@ public class CxfMtomProducerPayloadModeT
 
             public void process(Exchange exchange) throws Exception {
                 exchange.setPattern(ExchangePattern.InOut);
-                List<Element> elements = new ArrayList<Element>();
-                elements.add(DOMUtils.readXml(new StringReader(MtomTestHelper.REQ_MESSAGE)).getDocumentElement());
+                List<Source> elements = new ArrayList<Source>();
+                elements.add(new DOMSource(DOMUtils.readXml(new StringReader(MtomTestHelper.REQ_MESSAGE)).getDocumentElement()));
                 CxfPayload<SoapHeader> body = new CxfPayload<SoapHeader>(new ArrayList<SoapHeader>(),
-                    elements);
+                    elements, null);
                 exchange.getIn().setBody(body);
                 exchange.getIn().addAttachment(MtomTestHelper.REQ_PHOTO_CID, 
                     new DataHandler(new ByteArrayDataSource(MtomTestHelper.REQ_PHOTO_DATA, "application/octet-stream")));
@@ -116,11 +119,12 @@ public class CxfMtomProducerPayloadModeT
         ns.put("xop", MtomTestHelper.XOP_NS);
         
         XPathUtils xu = new XPathUtils(ns);
-        Element ele = (Element)xu.getValue("//ns:DetailResponse/ns:photo/xop:Include", out.getBody().get(0),
+        Element oute = new XmlConverter().toDOMElement(out.getBody().get(0));
+        Element ele = (Element)xu.getValue("//ns:DetailResponse/ns:photo/xop:Include", oute,
                                            XPathConstants.NODE);
         String photoId = ele.getAttribute("href").substring(4); // skip "cid:"
 
-        ele = (Element)xu.getValue("//ns:DetailResponse/ns:image/xop:Include", out.getBody().get(0),
+        ele = (Element)xu.getValue("//ns:DetailResponse/ns:image/xop:Include", oute,
                                            XPathConstants.NODE);
         String imageId = ele.getAttribute("href").substring(4); // skip "cid:"
 

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest.java?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/java/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest.java Mon Oct 17 13:21:32 2011
@@ -30,6 +30,8 @@ import javax.xml.bind.JAXBContext;
 import javax.xml.bind.JAXBElement;
 import javax.xml.bind.JAXBException;
 import javax.xml.namespace.QName;
+import javax.xml.transform.Source;
+import javax.xml.transform.dom.DOMSource;
 import javax.xml.ws.BindingProvider;
 import javax.xml.ws.Endpoint;
 import javax.xml.ws.Holder;
@@ -365,12 +367,12 @@ public class CxfMessageHeadersRelayTest 
             +   "</message></ns2:SOAPHeaderInfo>";
         String requestBody = "<ns2:inoutHeader xmlns:ns2=\"http://apache.org/camel/component/cxf/soap/headers\">" 
             + "<requestType>CXF user</requestType></ns2:inoutHeader>";
-        List<Element> elements = new ArrayList<Element>();
-        elements.add(DOMUtils.readXml(new StringReader(requestBody)).getDocumentElement());
+        List<Source> elements = new ArrayList<Source>();
+        elements.add(new DOMSource(DOMUtils.readXml(new StringReader(requestBody)).getDocumentElement()));
         final List<SoapHeader> headers = new ArrayList<SoapHeader>();
         headers.add(new SoapHeader(qname,
                                    DOMUtils.readXml(new StringReader(requestHeader)).getDocumentElement()));
-        final CxfPayload<SoapHeader> cxfPayload = new CxfPayload<SoapHeader>(headers, elements);
+        final CxfPayload<SoapHeader> cxfPayload = new CxfPayload<SoapHeader>(headers, elements, null);
         
         Exchange exchange = template.request(uri, new Processor() {
             public void process(Exchange exchange) throws Exception {
@@ -382,15 +384,17 @@ public class CxfMessageHeadersRelayTest 
         });
 
         CxfPayload<?> out = exchange.getOut().getBody(CxfPayload.class);
-        assertEquals(1, out.getBody().size());
+        assertEquals(1, out.getBodySources().size());
+
+        assertTrue(out.getBodySources().get(0) instanceof DOMSource);
 
         assertEquals(0, out.getHeaders().size());
         
-        String response = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" 
-            + "<ns2:inoutHeaderResponse xmlns:ns2=\"http://apache.org/camel/" 
+        String responseExp = "<ns2:inoutHeaderResponse xmlns:ns2=\"http://apache.org/camel/" 
             + "component/cxf/soap/headers\"><responseType>pass</responseType>" 
             + "</ns2:inoutHeaderResponse>";
-        assertEquals(response, XMLUtils.toString(out.getBody().get(0)));
+        String response = XMLUtils.toString(out.getBody().get(0));
+        assertTrue(response, response.contains(responseExp));
     }
 
     @Test

Modified: camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest-context.xml
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest-context.xml?rev=1185156&r1=1185155&r2=1185156&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest-context.xml (original)
+++ camel/branches/camel-2.8.x/components/camel-cxf/src/test/resources/org/apache/camel/component/cxf/soap/headers/CxfMessageHeadersRelayTest-context.xml Mon Oct 17 13:21:32 2011
@@ -71,6 +71,7 @@
                    xmlns:tns="http://apache.org/camel/component/cxf/soap/headers">              
       <cxf:properties>
           <entry key="dataFormat" value="PAYLOAD"/>
+          <entry key="allowStreaming" value="false"/>
       </cxf:properties>    
   </cxf:cxfEndpoint> 
 



Mime
View raw message