camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1164437 - in /camel/branches/camel-2.8.x: ./ components/camel-spring/src/main/java/org/apache/camel/component/xslt/ components/camel-spring/src/test/java/org/apache/camel/component/xslt/ components/camel-spring/src/test/resources/org/apach...
Date Fri, 02 Sep 2011 09:36:26 GMT
Author: davsclaus
Date: Fri Sep  2 09:36:26 2011
New Revision: 1164437

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


Added:
    camel/branches/camel-2.8.x/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltRouteFileTest.java
      - copied unchanged from r1153812, camel/trunk/components/camel-spring/src/test/java/org/apache/camel/component/xslt/XsltRouteFileTest.java
    camel/branches/camel-2.8.x/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/XsltRouteFileTest.xml
      - copied unchanged from r1153812, camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/component/xslt/XsltRouteFileTest.xml
Modified:
    camel/branches/camel-2.8.x/   (props changed)
    camel/branches/camel-2.8.x/components/camel-spring/src/main/java/org/apache/camel/component/xslt/XsltComponent.java

Propchange: camel/branches/camel-2.8.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Sep  2 09:36:26 2011
@@ -1 +1 @@
-/camel/trunk:1150651,1151054,1152170,1153829,1154684,1155230,1156108,1156260,1156277,1156479,1156524,1157348,1157798,1157831,1157878,1158153,1159171,1159174,1159326,1159457,1159460,1159606,1159682-1159683,1159867,1160547,1160637,1161010,1161082,1161524,1162309,1162395
+/camel/trunk:1150651,1151054,1152170,1153812,1153829,1154684,1155230,1156108,1156260,1156277,1156479,1156524,1157348,1157798,1157831,1157878,1158153,1159171,1159174,1159326,1159457,1159460,1159606,1159682-1159683,1159867,1160547,1160637,1161010,1161082,1161524,1162309,1162395

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

Modified: camel/branches/camel-2.8.x/components/camel-spring/src/main/java/org/apache/camel/component/xslt/XsltComponent.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-spring/src/main/java/org/apache/camel/component/xslt/XsltComponent.java?rev=1164437&r1=1164436&r2=1164437&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-spring/src/main/java/org/apache/camel/component/xslt/XsltComponent.java
(original)
+++ camel/branches/camel-2.8.x/components/camel-spring/src/main/java/org/apache/camel/component/xslt/XsltComponent.java
Fri Sep  2 09:36:26 2011
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.component.xslt;
 
+import java.io.File;
+import java.io.FileNotFoundException;
 import java.util.Map;
 import javax.xml.transform.TransformerConfigurationException;
 import javax.xml.transform.TransformerFactory;
@@ -31,6 +33,7 @@ import org.apache.camel.converter.jaxp.X
 import org.apache.camel.impl.ProcessorEndpoint;
 import org.apache.camel.util.ObjectHelper;
 import org.springframework.core.io.Resource;
+import org.springframework.core.io.UrlResource;
 
 /**
  * An <a href="http://camel.apache.org/xslt.html">XSLT Component</a>
@@ -149,7 +152,23 @@ public class XsltComponent extends Resou
     private void loadResource(XsltBuilder xslt, Resource resource) throws TransformerConfigurationException
{
         log.trace("{} loading schema resource: {}", this, resource);
         try {
-            xslt.setTransformerInputStream(resource.getInputStream());
+            if (resource instanceof UrlResource) {
+                // prefer to use file when a file based url
+                File file = resource.getFile();
+                if (file != null) {
+                    // check if the file exists and report a better error as the XSLT
+                    // will just say it cannot compile the stylesheet file
+                    if (!file.exists()) {
+                        throw new FileNotFoundException("File: " + file + " not found.");
+                    }
+                    xslt.setTransformerFile(file);
+                } else {
+                    xslt.setTransformerURL(resource.getURL());
+                }
+            } else {
+                // fallback and use input stream
+                xslt.setTransformerInputStream(resource.getInputStream());
+            }
         } catch (Exception e) {
             // include information about the resource in the caused exception, so its easier
for
             // end users to know which resource failed



Mime
View raw message