You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ha...@apache.org on 2012/01/05 02:56:07 UTC

svn commit: r1227433 - in /camel/trunk/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

Author: hadrian
Date: Thu Jan  5 01:56:06 2012
New Revision: 1227433

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

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

Modified: camel/trunk/tooling/camel-manual/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tooling/camel-manual/pom.xml?rev=1227433&r1=1227432&r2=1227433&view=diff
==============================================================================
--- camel/trunk/tooling/camel-manual/pom.xml (original)
+++ camel/trunk/tooling/camel-manual/pom.xml Thu Jan  5 01:56:06 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/trunk/tooling/maven/maven-html-to-pdf/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/tooling/maven/maven-html-to-pdf/pom.xml?rev=1227433&r1=1227432&r2=1227433&view=diff
==============================================================================
--- camel/trunk/tooling/maven/maven-html-to-pdf/pom.xml (original)
+++ camel/trunk/tooling/maven/maven-html-to-pdf/pom.xml Thu Jan  5 01:56:06 2012
@@ -33,10 +33,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>
@@ -46,11 +42,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/trunk/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/HtmlToPdfMojo.java
URL: http://svn.apache.org/viewvc/camel/trunk/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/HtmlToPdfMojo.java?rev=1227433&r1=1227432&r2=1227433&view=diff
==============================================================================
--- camel/trunk/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/HtmlToPdfMojo.java (original)
+++ camel/trunk/tooling/maven/maven-html-to-pdf/src/main/java/org/apache/camel/maven/HtmlToPdfMojo.java Thu Jan  5 01:56:06 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()) {
@@ -283,6 +293,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);
@@ -304,7 +321,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.");
     }