@@ -53,6 +53,7 @@
*/
package org.apache.tools.ant.taskdefs.optional.jsp.compilers;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;
@@ -87,13 +88,37 @@ public class JspCompilerAdapterFactory {
*/
public static JspCompilerAdapter getCompiler(String compilerType, Task task)
throws BuildException {
return getCompiler(compilerType, task,
new AntClassLoader(task.getProject(), null));
}
/**
* Based on the parameter passed in, this method creates the necessary
* factory desired.
*
* The current mapping for compiler names are as follows:
* <ul><li>jasper = jasper compiler (the default)
* <li><i>a fully quallified classname</i> = the name of a jsp compiler
* adapter
* </ul>
*
* @param compilerType either the name of the desired compiler, or the
* full classname of the compiler's adapter.
* @param task a task to log through.
* @param loader AntClassLoader with which the compiler should be loaded
* @throws BuildException if the compiler type could not be resolved into
* a compiler adapter.
*/
public static JspCompilerAdapter getCompiler(String compilerType, Task task,
AntClassLoader loader)
throws BuildException {
/* If I've done things right, this should be the extent of the
* conditional statements required.
*/
if (compilerType.equalsIgnoreCase("jasper")) {
return new JasperC();
}
return resolveClassName(compilerType);
return resolveClassName(compilerType, loader );
}
/**
@@ -101,13 +126,15 @@ public class JspCompilerAdapterFactory {
* Throws a fit if it can't.
*
* @param className The fully qualified classname to be created.
* @param classloader Classloader with which to load the class
* @throws BuildException This is the fit that is thrown if className
* isn't an instance of JspCompilerAdapter.
*/
private static JspCompilerAdapter resolveClassName(String className)
private static JspCompilerAdapter resolveClassName(String className,
AntClassLoader classloader)
throws BuildException {
try {
Class c = Class.forName (className);
Class c = classloader.findClass (className);
Object o = c.newInstance();
return (JspCompilerAdapter) o;
} catch (ClassNotFoundException cnfe) {