camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hadr...@apache.org
Subject svn commit: r1227435 - in /camel/branches/camel-2.8.x/tooling: camel-manual/pom.xml maven/maven-html-to-pdf/pom.xml maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/HtmlToPdfMojo.java
Date Thu, 05 Jan 2012 01:58:38 GMT
Author: hadrian
Date: Thu Jan  5 01:58:38 2012
New Revision: 1227435

URL: http://svn.apache.org/viewvc?rev=1227435&view=rev
Log:
CAMEL-3774. Patch applied with thanks to Babak.

Modified:
    camel/branches/camel-2.8.x/tooling/camel-manual/pom.xml
    camel/branches/camel-2.8.x/tooling/maven/maven-html-to-pdf/pom.xml
    camel/branches/camel-2.8.x/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/HtmlToPdfMojo.java

Modified: camel/branches/camel-2.8.x/tooling/camel-manual/pom.xml
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/tooling/camel-manual/pom.xml?rev=1227435&r1=1227434&r2=1227435&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/tooling/camel-manual/pom.xml (original)
+++ camel/branches/camel-2.8.x/tooling/camel-manual/pom.xml Thu Jan  5 01:58:38 2012
@@ -74,6 +74,7 @@
               <replaceValue><![CDATA[
                   <h3>Version ${project.version}</h3>
               ]]></replaceValue>
+              <transformerFactoryClassName>org.apache.xalan.xsltc.trax.TransformerFactoryImpl</transformerFactoryClassName>
             </configuration>
           </plugin>
           <plugin>

Modified: camel/branches/camel-2.8.x/tooling/maven/maven-html-to-pdf/pom.xml
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/tooling/maven/maven-html-to-pdf/pom.xml?rev=1227435&r1=1227434&r2=1227435&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/tooling/maven/maven-html-to-pdf/pom.xml (original)
+++ camel/branches/camel-2.8.x/tooling/maven/maven-html-to-pdf/pom.xml Thu Jan  5 01:58:38
2012
@@ -32,10 +32,6 @@
   <dependencies>
     <dependency>
       <groupId>org.apache.camel</groupId>
-      <artifactId>camel-core</artifactId>
-    </dependency>    
-    <dependency>
-      <groupId>org.apache.camel</groupId>
       <artifactId>camel-tagsoup</artifactId>
     </dependency>    
     <dependency>
@@ -45,11 +41,18 @@
     </dependency>
     <dependency>
       <groupId>org.slf4j</groupId>
-      <artifactId>slf4j-api</artifactId>
-    </dependency>
-    <dependency>
-      <groupId>org.slf4j</groupId>
       <artifactId>slf4j-log4j12</artifactId>
     </dependency>
+	<dependency>
+      <groupId>xalan</groupId>
+      <artifactId>xalan</artifactId>
+      <version>${xalan-version}</version>
+      <exclusions>
+        <exclusion>
+          <groupId>xml-apis</groupId>
+          <artifactId>xml-apis</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
   </dependencies>
 </project>

Modified: camel/branches/camel-2.8.x/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/HtmlToPdfMojo.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/HtmlToPdfMojo.java?rev=1227435&r1=1227434&r2=1227435&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/HtmlToPdfMojo.java
(original)
+++ camel/branches/camel-2.8.x/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/HtmlToPdfMojo.java
Thu Jan  5 01:58:38 2012
@@ -52,6 +52,8 @@ import org.codehaus.plexus.util.cli.Stre
  */
 public class HtmlToPdfMojo extends AbstractMojo {
 
+    private static final String XSLT_SYSTEM_PROPERTY_KEY = "javax.xml.transform.TransformerFactory";
+
     /**
      * The URL to the confluence page to convert.
      *
@@ -158,6 +160,14 @@ public class HtmlToPdfMojo extends Abstr
      */
     private String classifier;
 
+    /**
+     * The XSL transformer factory class name to be used which will be set through the <code>javax.xml.transform.TransformerFactory</code>
system property.
+     *
+     * @parameter
+     */
+    private String transformerFactoryClassName;
+
+
     public void execute() throws MojoExecutionException {
         File outputDir = new File(pdf).getParentFile();
         if (!outputDir.exists()) {
@@ -282,6 +292,13 @@ public class HtmlToPdfMojo extends Abstr
     }
 
     private String downloadContent() throws MalformedURLException, MojoExecutionException
{
+        // avoid the usage of default xslt by jdk as that could cause problems
+        String previousTransformerFactoryClassName = null;
+        if (transformerFactoryClassName != null) {
+            previousTransformerFactoryClassName = System.setProperty(XSLT_SYSTEM_PROPERTY_KEY,
transformerFactoryClassName);
+            getLog().info("Set the XSL transformer factory class name to be '" + transformerFactoryClassName
+ "'");
+        }
+
         String contentTag = "<div class=\"" + contentDivClass + "\"";
 
         getLog().info("Downloading: " + page);
@@ -303,7 +320,20 @@ public class HtmlToPdfMojo extends Abstr
                 getLog().error("Download or validation of '" + page + "' failed: " + e);
                 return null;
             }
-        }        
+        } finally {
+            // avoid any side effects by other camel modules (for example while running the
tests) and reset the system property 
+            if (transformerFactoryClassName != null) {
+                if (previousTransformerFactoryClassName == null) {
+                    // remove the set system property
+                    System.getProperties().remove(XSLT_SYSTEM_PROPERTY_KEY);
+                    getLog().info("Removed the set XSL transformer factory class name '"
+ transformerFactoryClassName + "' from the system properties");
+                } else {
+                    // reset the previous system property value to whatever it was before
+                    System.setProperty(XSLT_SYSTEM_PROPERTY_KEY, previousTransformerFactoryClassName);
+                    getLog().info("Resetted the XSL transformer factory class name to be
'" + previousTransformerFactoryClassName + "'");
+                }
+            }
+        }
         throw new MojoExecutionException("The '" + page + "' page did not have a " + contentTag
+ " element.");
     }
 



Mime
View raw message