You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by bo...@apache.org on 2010/08/05 20:45:11 UTC

svn commit: r982729 - /ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java

Author: bodewig
Date: Thu Aug  5 18:45:11 2010
New Revision: 982729

URL: http://svn.apache.org/viewvc?rev=982729&view=rev
Log:
better fix for bug 49271 as suggested by Jesse

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java?rev=982729&r1=982728&r2=982729&view=diff
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java Thu Aug  5 18:45:11 2010
@@ -108,10 +108,6 @@ public class XSLTProcess extends Matchin
     /** for resolving entities such as dtds */
     private XMLCatalog xmlCatalog = new XMLCatalog();
 
-    /** Name of the TRAX Liaison class */
-    private static final String TRAX_LIAISON_CLASS =
-                        "org.apache.tools.ant.taskdefs.optional.TraXLiaison";
-
     /** Utilities used for file operations */
     private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();
 
@@ -340,6 +336,8 @@ public class XSLTProcess extends Matchin
             return;
         }
         try {
+            setupLoader();
+
             if (sysProperties.size() > 0) {
                 sysProperties.setSystem();
             }
@@ -676,13 +674,12 @@ public class XSLTProcess extends Matchin
     private void resolveProcessor(String proc) throws Exception {
         String classname;
         if (proc.equals(PROCESSOR_TRAX)) {
-            classname = TRAX_LIAISON_CLASS;
+            liaison = new org.apache.tools.ant.taskdefs.optional.TraXLiaison();
         } else {
             //anything else is a classname
-            classname = proc;
+            Class clazz = loadClass(proc);
+            liaison = (XSLTLiaison) clazz.newInstance();
         }
-        Class clazz = loadClass(classname);
-        liaison = (XSLTLiaison) clazz.newInstance();
     }
 
     /**
@@ -695,15 +692,26 @@ public class XSLTProcess extends Matchin
      * @exception Exception if the class could not be loaded.
      */
     private Class loadClass(String classname) throws Exception {
-        if (classpath == null) {
+        setupLoader();
+        if (loader == null) {
             return Class.forName(classname);
         }
-        loader = getProject().createClassLoader(classpath);
-        loader.setThreadContextLoader();
         return Class.forName(classname, true, loader);
     }
 
     /**
+     * If a custom classpath has been defined but no loader created
+     * yet, create the classloader and set it as the context
+     * classloader.
+     */
+    private void setupLoader() {
+        if (classpath != null && loader == null) {
+            loader = getProject().createClassLoader(classpath);
+            loader.setThreadContextLoader();
+        }
+    }
+
+    /**
      * Specifies the output name for the styled result from the
      * <tt>in</tt> attribute; required if <tt>in</tt> is set
      *