On 4/5/07, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:

Send Jump-pilot-devel mailing list submissions to
        jump-pilot-devel@lists.sourceforge.net

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
or, via email, send a message with subject or body 'help' to
        [EMAIL PROTECTED]

You can reach the person managing the list at
        [EMAIL PROTECTED]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Jump-pilot-devel digest..."


Today's Topics:

   1. Help with a Java problem... (Sunburned Surveyor)
   2. Re: Help with a Java problem... (Jonathan Aquino)
   3. Re: Help with a Java problem... (Sunburned Surveyor)
   4. Re: Help with a Java problem... (Edgar Soldin)
   5. Re: Help with a Java problem... (Sunburned Surveyor)


----------------------------------------------------------------------

Message: 1
Date: Wed, 4 Apr 2007 15:33:29 -0700
From: "Sunburned Surveyor" <[EMAIL PROTECTED]>
Subject: [JPP-Devel] Help with a Java problem...
To: "List for discussion of JPP development and use."
        <jump-pilot-devel@lists.sourceforge.net>
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"

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
-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

Message: 2
Date: Wed, 4 Apr 2007 19:18:40 -0700
From: "Jonathan Aquino" <[EMAIL PROTECTED]>
Subject: Re: [JPP-Devel] Help with a Java problem...
To: "'List for discussion of JPP development and use.'"
        <jump-pilot-devel@lists.sourceforge.net>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="us-ascii"

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

-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

Message: 3
Date: Thu, 5 Apr 2007 07:01:05 -0700
From: "Sunburned Surveyor" <[EMAIL PROTECTED]>
Subject: Re: [JPP-Devel] Help with a Java problem...
To: "List for discussion of JPP development and use."
        <jump-pilot-devel@lists.sourceforge.net>
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"

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
>
>
-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

Message: 4
Date: Thu, 05 Apr 2007 17:49:56 +0200
From: Edgar Soldin <[EMAIL PROTECTED]>
Subject: Re: [JPP-Devel] Help with a Java problem...
To: "List for discussion of JPP development and use."
        <jump-pilot-devel@lists.sourceforge.net>
Message-ID: <[EMAIL PROTECTED]>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

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());
  }
}




------------------------------

Message: 5
Date: Thu, 5 Apr 2007 10:05:11 -0700
From: "Sunburned Surveyor" <[EMAIL PROTECTED]>
Subject: Re: [JPP-Devel] Help with a Java problem...
To: "List for discussion of JPP development and use."
        <jump-pilot-devel@lists.sourceforge.net>
Message-ID:
        <[EMAIL PROTECTED]>
Content-Type: text/plain; charset="iso-8859-1"

Edgar and Jon.

I have decided to just use a text file containing the name of each class
that
I need to load and the create and object from.

Although this requires a little more effort to install the plug-in, it is
a
whole lot
easier to program. I'll probably write a little helper class that appends
the class
name to the text file that programmers can use in a simple installer.

I'll have more details when I finish with the design and documentation of
the pluggable renderers for OpenJUMP.

The Sunburned Surveyor


On 4/5/07, Edgar Soldin <[EMAIL PROTECTED]> wrote:
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...

------------------------------

-------------------------------------------------------------------------
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


End of Jump-pilot-devel Digest, Vol 11, Issue 6
***********************************************

-------------------------------------------------------------------------
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