camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1362128 - in /camel/branches/camel-2.10.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf: CxfEndpoint.java converter/CxfPayloadConverter.java
Date Mon, 16 Jul 2012 16:56:09 GMT
Author: dkulp
Date: Mon Jul 16 16:56:09 2012
New Revision: 1362128

URL: http://svn.apache.org/viewvc?rev=1362128&view=rev
Log:
Merged revisions 1362123 via  git cherry-pick from
https://svn.apache.org/repos/asf/camel/trunk

........
  r1362123 | dkulp | 2012-07-16 12:53:52 -0400 (Mon, 16 Jul 2012) | 2 lines

  [CAMEL-5449] Try converting to Source first

........

Modified:
    camel/branches/camel-2.10.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
    camel/branches/camel-2.10.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java

Modified: camel/branches/camel-2.10.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java?rev=1362128&r1=1362127&r2=1362128&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/CxfEndpoint.java
Mon Jul 16 16:56:09 2012
@@ -29,6 +29,7 @@ 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.transform.stream.StreamSource;
 import javax.xml.ws.WebServiceProvider;
 import javax.xml.ws.handler.Handler;
 
@@ -88,6 +89,7 @@ import org.apache.cxf.service.factory.Re
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.MessagePartInfo;
 import org.apache.cxf.staxutils.StaxSource;
+import org.apache.cxf.staxutils.StaxUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -916,6 +918,19 @@ public class CxfEndpoint extends Default
                     }
                 }
                 return r.getLocalName();
+            } else if (source instanceof StreamSource) {
+                //flip to stax so we can get the name
+                XMLStreamReader reader = StaxUtils.createXMLStreamReader(source);
+                StaxSource src2 = new StaxSource(reader);
+                sources.set(i, src2);
+                if (reader.getEventType() == XMLStreamReader.START_DOCUMENT) {
+                    try {
+                        reader.nextTag();
+                    } catch (XMLStreamException e) {
+                        //ignore
+                    }
+                }
+                return reader.getLocalName();
             }
             return null;
         }

Modified: camel/branches/camel-2.10.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.10.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java?rev=1362128&r1=1362127&r2=1362128&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
(original)
+++ camel/branches/camel-2.10.x/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
Mon Jul 16 16:56:09 2012
@@ -20,6 +20,8 @@ import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 
+import javax.xml.transform.Source;
+
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -65,6 +67,14 @@ public final class CxfPayloadConverter {
         }
         return new CxfPayload<T>(headers, body);
     }
+    
+    @Converter
+    public static <T> CxfPayload<T> sourceToCxfPayload(Source src, Exchange exchange)
{
+        List<T> headers = new ArrayList<T>();
+        List<Source> body = new ArrayList<Source>();
+        body.add(src);
+        return new CxfPayload<T>(headers, body, null);
+    }
 
     @Converter
     public static <T> NodeList cxfPayloadToNodeList(CxfPayload<T> payload, Exchange
exchange) {
@@ -87,6 +97,13 @@ public final class CxfPayloadConverter {
         // use fallback type converter, so we can probably convert into
         // CxfPayloads from other types
         if (type.isAssignableFrom(CxfPayload.class)) {
+            if (!value.getClass().isArray()) {
+                TypeConverter tc = registry.lookup(Source.class, value.getClass());
+                if (tc != null) {
+                    Source src = tc.convertTo(Source.class, exchange, value);
+                    return (T) sourceToCxfPayload(src, exchange);
+                }                
+            }
             TypeConverter tc = registry.lookup(NodeList.class, value.getClass());
             if (tc != null) {
                 NodeList nodeList = tc.convertTo(NodeList.class, exchange, value);



Mime
View raw message