Hello Sunburned,

also to minimize the jars searched on you might instantiate a new 
Classloader (e.g. java.net.URLClassLoader) containing only a few 
selected jars e.g. in some folder or so. I found examples using a 
classloader with some other api classes to find classes by interface or 
implemented method. But if  all have to be instantiated this will be 
inperformant true, Still may they don't have too.. long time since ;)

regards ede

PS: just added an example for the classloader building
--

-- from GT2ReaderWriterExtension.java START-->

    public static ClassLoader createLoader(){
            final String SEP = System.getProperty("file.separator");
            String mod_dir = SEP+"lib"+SEP+"ext"+SEP+"readwrite";
            File workingDir = new File(System.getProperty("user.dir"));
           
            System.out.println("Working Dir: "+workingDir.getPath());
           
           
            File extensionDir = new File(workingDir.getPath()+mod_dir);
            if (!extensionDir.exists())
                extensionDir = new 
File(workingDir.getPath()+SEP+".."+mod_dir);
           
            System.out.println("Extension Dir: 
"+extensionDir.getPath());           
           
            File[] entries = extensionDir.listFiles();
            Collection urls = new Vector();
            try {
                urls.add(extensionDir.toURL());
            } catch (MalformedURLException e1) {}
            for (int i = 0; entries != null && i < entries.length; i++) {
                try {
                    urls.add(entries[i].toURL());
                } catch (MalformedURLException e) { e.printStackTrace(); }
            }
           
            System.out.println("ExtDir contains: "+urls.toString());
       
            return new URLClassLoader((URL[])urls.toArray(new URL[]{}));   
    }

<-- ENDE --

> Jon,
>
> That makes a lot of sense. Thanks for your explanation.
>
> Landon
>
>
> On 4/4/07, Jonathan Aquino <[EMAIL PROTECTED]> wrote:
>>
>>  If I remember correctly, for JUMP it was quite slow to determine this
>> programatically (I think you have to instantiate every class in the 
>> jar).
>> So instead we search based on the _name_ of the class, i.e., 
>> *PlugIn.class
>> .
>>
>> You should be able to do the same in your case if all classes that
>> implement that interface are named in some computable way.
>>
>> Jon
>>
>>
>>
>>  -----Original Message-----
>> *From:* [EMAIL PROTECTED] [mailto:
>> [EMAIL PROTECTED] *On Behalf Of *Sunburned
>> Surveyor
>> *Sent:* Wednesday, April 04, 2007 3:33 PM
>> *To:* List for discussion of JPP development and use.
>> *Subject:* [JPP-Devel] Help with a Java problem...
>>
>> I'm hoping you guys might be able to help me out with a Java problem I'm
>> having.
>>
>> I can't seem to find a way to determine if a JAR file contains a class
>> that implements a particular interface. I need to be able to do discover
>> this programmatically. If the JAR file does contain an implementation 
>> of the
>> interface, I need to be able to obtain the Class object for that
>> implementation. I've been reading online, but haven't quite found what I
>> need. I think JUMP does something similar when it loads plug-ins, but I
>> peeked in the source code for the PlugInManager class and the
>> WorkbenchPropertiesFile class and didn't find what I needed.
>>
>> I'm guessing it involves using the getEntry() method of the
>> java.util.jar.JarFile class. Is this correct?
>>
>> After the Entry object is returned by getEntry(), how do I convert it 
>> to a
>> Class file?
>>
>> Thanks,
>>
>> The Sunburned Surveyor
>>
>>
>> ------------------------------------------------------------------------- 
>>
>> Take Surveys. Earn Cash. Influence the Future of IT
>> Join SourceForge.net's Techsay panel and you'll get the chance to share
>> your
>> opinions on IT & business topics through brief surveys-and earn cash
>> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV 
>>
>> _______________________________________________
>> Jump-pilot-devel mailing list
>> Jump-pilot-devel@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>>
>>
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> Take Surveys. Earn Cash. Influence the Future of IT
> Join SourceForge.net's Techsay panel and you'll get the chance to share your
> opinions on IT & business topics through brief surveys-and earn cash
> http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
> ------------------------------------------------------------------------
>
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>   


-- 
public class WhoDidIt{ // A comment. I love comments 
  private static Person sender;

  public static void main (String[] foo){

  sender = new Person();
  sender.setName(new String[]{"Edgar", "Soldin"});

  Address address = new Address();
  address.setStreet("Stadtweg 119");
  address.setZip(39116);
  address.setCity("Magdeburg");
  address.setCountry("Germany");

  sender.setAddress(address);

  sender.setMobilePhone(" +49(0)171-2782880 ");
  sender.setWebSiteUrl(" http://www.soldin.de ");
  sender.setEmail(" [EMAIL PROTECTED] ");
  sender.setPGPPublicKey(" http://www.soldin.de/edgar_soldin.asc ");
  sender.setGender(true);

  System.out.println(sender.toString());
  }
}


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to