camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1366592 - in /camel/branches/camel-2.10.x: ./ examples/camel-example-gae/pom.xml examples/camel-example-gae/src/main/java/org/apache/camel/example/gae/TutorialRouteBuilder.java
Date Sat, 28 Jul 2012 04:32:39 GMT
Author: ningjiang
Date: Sat Jul 28 04:32:38 2012
New Revision: 1366592

URL: http://svn.apache.org/viewvc?rev=1366592&view=rev
Log:
Merged revisions 1365939 via svnmerge from 
https://svn.apache.org/repos/asf/camel/trunk

........
  r1365939 | ningjiang | 2012-07-26 18:37:15 +0800 (Thu, 26 Jul 2012) | 1 line
  
  CAMEL-5470 Fix the issue of camel-example-gae gtask issue
........

Modified:
    camel/branches/camel-2.10.x/   (props changed)
    camel/branches/camel-2.10.x/examples/camel-example-gae/pom.xml
    camel/branches/camel-2.10.x/examples/camel-example-gae/src/main/java/org/apache/camel/example/gae/TutorialRouteBuilder.java

Propchange: camel/branches/camel-2.10.x/
------------------------------------------------------------------------------
  Merged /camel/trunk:r1365939

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

Modified: camel/branches/camel-2.10.x/examples/camel-example-gae/pom.xml
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/examples/camel-example-gae/pom.xml?rev=1366592&r1=1366591&r2=1366592&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/examples/camel-example-gae/pom.xml (original)
+++ camel/branches/camel-2.10.x/examples/camel-example-gae/pom.xml Sat Jul 28 04:32:38 2012
@@ -51,7 +51,6 @@
             <artifactId>slf4j-jdk14</artifactId>
             <version>${slf4j-version}</version>
         </dependency>
-		
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>

Modified: camel/branches/camel-2.10.x/examples/camel-example-gae/src/main/java/org/apache/camel/example/gae/TutorialRouteBuilder.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.10.x/examples/camel-example-gae/src/main/java/org/apache/camel/example/gae/TutorialRouteBuilder.java?rev=1366592&r1=1366591&r2=1366592&view=diff
==============================================================================
--- camel/branches/camel-2.10.x/examples/camel-example-gae/src/main/java/org/apache/camel/example/gae/TutorialRouteBuilder.java
(original)
+++ camel/branches/camel-2.10.x/examples/camel-example-gae/src/main/java/org/apache/camel/example/gae/TutorialRouteBuilder.java
Sat Jul 28 04:32:38 2012
@@ -16,13 +16,19 @@
  */
 package org.apache.camel.example.gae;
 
+import java.io.InputStream;
+
+import javax.xml.parsers.DocumentBuilderFactory;
+
 import org.w3c.dom.Document;
 
 import org.apache.camel.Exchange;
+import org.apache.camel.RuntimeCamelException;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.gae.mail.GMailBinding;
 import org.apache.camel.processor.aggregate.AggregationStrategy;
 
+
 public class TutorialRouteBuilder extends RouteBuilder {
 
     @Override
@@ -49,10 +55,30 @@ public class TutorialRouteBuilder extend
         return new AggregationStrategy() {
             public Exchange aggregate(Exchange reportExchange, Exchange weatherExchange)
{
                 ReportData reportData = reportExchange.getIn().getBody(ReportData.class);
-                reportData.setWeather(weatherExchange.getIn().getBody(Document.class));
+                reportData.setWeather(toDocument(weatherExchange.getIn().getBody(InputStream.class)));
                 return reportExchange;
             }
         };
     }
     
+    // As GAE have trouble to load the  javax.xml.transform.stax.StAXSource which is used
the XmlConverter
+    // Now we just do the transformation ourself.
+    private static DocumentBuilderFactory createDocumentBuilderFactory() {
+        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+        factory.setNamespaceAware(true);
+        factory.setIgnoringElementContentWhitespace(true);
+        factory.setIgnoringComments(true);
+        return factory;
+    }
+    
+    private static Document toDocument(InputStream stream) {
+        DocumentBuilderFactory factory = createDocumentBuilderFactory();
+        try {
+            Document doc =  factory.newDocumentBuilder().parse(stream);
+            return doc;
+        } catch (Exception ex) {
+            throw new RuntimeCamelException(ex);
+        }
+    }
+    
 }



Mime
View raw message