camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1362624 - /camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
Date Tue, 17 Jul 2012 19:49:52 GMT
Author: dkulp
Date: Tue Jul 17 19:49:52 2012
New Revision: 1362624

URL: http://svn.apache.org/viewvc?rev=1362624&view=rev
Log:
Optimized "to document" for cxf payload

Modified:
    camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java

Modified: camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java?rev=1362624&r1=1362623&r2=1362624&view=diff
==============================================================================
--- camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
(original)
+++ camel/trunk/components/camel-cxf/src/main/java/org/apache/camel/component/cxf/converter/CxfPayloadConverter.java
Tue Jul 17 19:49:52 2012
@@ -20,6 +20,7 @@ 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;
 
@@ -34,6 +35,7 @@ import org.apache.camel.FallbackConverte
 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 {
@@ -144,6 +146,17 @@ public final class CxfPayloadConverter {
             CxfPayload<?> payload = (CxfPayload<?>) value;
             
             if (payload.getBodySources().size() == 1) {
+                if (type.isAssignableFrom(Document.class)) {
+                    Source s = payload.getBodySources().get(0);
+                    Document d;
+                    try {
+                        d = StaxUtils.read(s);
+                    } catch (XMLStreamException e) {
+                        throw new RuntimeException(e);
+                    }
+                    payload.getBodySources().set(0, new DOMSource(d.getDocumentElement()));
+                    return type.cast(d);
+                }
                 TypeConverter tc = registry.lookup(type, Source.class);
                 if (tc != null) {
                     T t = tc.convertTo(type, payload.getBodySources().get(0));



Mime
View raw message