Browse Source

better fix for bug 49271 as suggested by Jesse

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@982729 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 15 years ago
parent
commit
0b52075bb1
1 changed files with 19 additions and 11 deletions
  1. +19
    -11
      src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java

+ 19
- 11
src/main/org/apache/tools/ant/taskdefs/XSLTProcess.java View File

@@ -108,10 +108,6 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
/** for resolving entities such as dtds */ /** for resolving entities such as dtds */
private XMLCatalog xmlCatalog = new XMLCatalog(); 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 */ /** Utilities used for file operations */
private static final FileUtils FILE_UTILS = FileUtils.getFileUtils(); private static final FileUtils FILE_UTILS = FileUtils.getFileUtils();


@@ -340,6 +336,8 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
return; return;
} }
try { try {
setupLoader();

if (sysProperties.size() > 0) { if (sysProperties.size() > 0) {
sysProperties.setSystem(); sysProperties.setSystem();
} }
@@ -676,13 +674,12 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
private void resolveProcessor(String proc) throws Exception { private void resolveProcessor(String proc) throws Exception {
String classname; String classname;
if (proc.equals(PROCESSOR_TRAX)) { if (proc.equals(PROCESSOR_TRAX)) {
classname = TRAX_LIAISON_CLASS;
liaison = new org.apache.tools.ant.taskdefs.optional.TraXLiaison();
} else { } else {
//anything else is a classname //anything else is a classname
classname = proc;
Class clazz = loadClass(proc);
liaison = (XSLTLiaison) clazz.newInstance();
} }
Class clazz = loadClass(classname);
liaison = (XSLTLiaison) clazz.newInstance();
} }


/** /**
@@ -695,14 +692,25 @@ public class XSLTProcess extends MatchingTask implements XSLTLogger {
* @exception Exception if the class could not be loaded. * @exception Exception if the class could not be loaded.
*/ */
private Class loadClass(String classname) throws Exception { private Class loadClass(String classname) throws Exception {
if (classpath == null) {
setupLoader();
if (loader == null) {
return Class.forName(classname); return Class.forName(classname);
} }
loader = getProject().createClassLoader(classpath);
loader.setThreadContextLoader();
return Class.forName(classname, true, loader); 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 * Specifies the output name for the styled result from the
* <tt>in</tt> attribute; required if <tt>in</tt> is set * <tt>in</tt> attribute; required if <tt>in</tt> is set


Loading…
Cancel
Save