You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Yves Martin <yv...@elca.ch> on 2004/11/25 16:35:53 UTC

How can I get the ClassLoader that loaded a URI ?

   Hello,

 I'm creating complex tasks with Ant and my problem can sumup to the question
 in subject.

 What I'm trying to do:

 1.  a.jar loaded in 'uri:a' with a 'loadclass' task declared. 'loadclass' will
     work with implementation of 'mycontract' interface.

   If I use <a:loadclass name="myclass" xmlns:a="uri:a"/> with myclass included
   in a.jar and implementing the 'mycontract' interface, it works - I use a
   simple Class.forName to get it.

 2. b.jar loaded in 'uri:b' with another class 'bclass', implementing
    'mycontract'.

   <a:loadclass name="bclass" xmlns:a="uri:a"/> does not work. Of course,
   bclass.class is not in 'loadclass' ClassLoader - so Class.forName is not
   enough.

 I would like to improve my task to do:
   <a:loadclass name="bclass" sourceuri="uri:b" xmlns:a="uri:a"/>

 That's way, 'loadclass' can lookup for the "uri:b" ClassLoader and loads
 "bclass".

 How can I lookup for a URI ClassLoader ? Thanks in advance.

 'myclass' and 'bclass' are not tasks but simple POJO. If they were tasks, it
 is "easy" to execute them from its respective URI. I'm looking for a way to
 keep them POJO.

 Best regards,
-- 
Yves Martin


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