ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cost...@covalent.net
Subject RE: classloader for factories
Date Sat, 18 May 2002 23:50:34 GMT
On Sat, 18 May 2002, Keith Wannamaker wrote:

> Ok, of course the earlier attempt won't work because JspC
> will be deferred to the parent classloader.
> 
> This is the solution I came up with is this:

My experience - the 'correct' solution is to make sure
that all code that loads a class by name must use 
the thread class loader first.

I believe ant is already setting the thread class loader
when executing a task ( or it should do so if it doesn't 
already ). 

This will allow the code to be used in webapps and in 
many other environments.

There are workarounds - like adding a setter and/or 
extending the class, etc.

Costin

> 
> I extended JspC to create my own dummy jspc task.
> Since this new class lives in my custom task jar, any
> classes (adapters) it loads will be loaded from the
> taskdef classpath rather than the system classpath.
> 
> However, can this change be made, so the new stub jspc
> class does at least one useful thing (sets the default
> compiler)?
> 
> Thanks,
> Keith
> 
> 
> Index: src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java
> ===================================================================
> RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/
> jsp/JspC.java,v
> retrieving revision 1.16
> diff -u -r1.16 JspC.java
> --- src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java       15 Apr 2
> 002 14:56:33 -0000      1.16
> +++ src/main/org/apache/tools/ant/taskdefs/optional/jsp/JspC.java       18 May 2
> 002 14:50:36 -0000
> @@ -117,7 +117,7 @@
>      private File destDir;
>      private String packageName ;
>      /** name of the compiler to use */
> -    private String compilerName = "jasper";
> +    protected String compilerName = "jasper";
> 
>      /**
>       *  -ieplugin <clsid>Java Plugin classid for Internet Explorer
> 
> 
> 
> --
> To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>
> 
> 


--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message