ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Bodewig <bode...@apache.org>
Subject Re: Classloader question
Date Wed, 17 Oct 2001 09:03:25 GMT
On Thu, 11 Oct 2001, Conor MacNeill <conor@cortexebusiness.com.au>
wrote:

> We could say that the context loader will be set for the execute
> method but not for the setter methods.

Oops, didn't think about the setters (and nested element handlers) at
all.  Setters and nested element handlers could need classes that
cannot be loaded from the system classloader, and you'd probably
expect child elements of a task to see the same classloader as the
task itself.

Maybe we should strongly discourage task writers to instantiate other
tasks directly and instead provide some wrapper class that calls
IntrospectionHelper under the covers (and could set the context
classloader) - something like

   private Task realTask;

   public ProxiedTask(Project project, String name) {
      realTask = project.createTask(name);
   }

   public void setAttribute(String name, String stringifiedValue) {
      ... set classloader if necessary and delegate to IntrospectionHelper ...
   }

... and so on ...

And tasks that want to access other tasks use ProxiedTask as an extra
indirection - this would also allow the task writer to change the
signature of a setter method without bothering the dependent task.

Stefan

Mime
View raw message