Find plugins which are extending a specifc class

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Find plugins which are extending a specifc class

jumpfunky
Dear list,

I wondering if it is possible to scan all available plugins if they are
implementing a specific class.

Any ideas?

Cheers,
Thorsten

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Find plugins which are extending a specifc class

John Hayes
Hi Thorsten,

It may not be exactly what you had in mind, but I believe you can use the Unix/Linux/OS X 'grep' and 'xargs' command for this like so (from the ImageJ directory):
> find plugins | xargs grep PlugInFilter

This searches for PlugInFilter within all the files under the plugins directory and should work on normal .class and .jar files as well as .java files if they happen to be in there.

Alternatively, I believe Windows and OS X search utilities may dig through files, and since class names are typically encoded as text strings, even within .class binary files, one of those may work for your needs as well.

HTH,

John

Le 20 févr. 2015 à 09:43, Thorsten Wagner a écrit :

> Dear list,
>
> I wondering if it is possible to scan all available plugins if they are
> implementing a specific class.
>
> Any ideas?
>
> Cheers,
> Thorsten
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Find plugins which are extending a specifc class

ctrueden
In reply to this post by jumpfunky
Hi Thorsten,

> I wondering if it is possible to scan all available plugins if they
> are implementing a specific class.

Are you interested in this information only as a human? Or do you need to
know the computer to know programmatically at runtime for some reason?

If you are interested as a human, you can put all your code into an IDE
such as Eclipse, then view the Type Hierarchy of the specific class of
interest.

If you have no IDE and want to scan arbitrary binaries, you can use the
javap tool. I whipped up a script to demonstrate [1].

If you need the computer to know at runtime, I'd like to know more about
your use case. One solution is the SciJava/ImageJ2 plugin framework, which
supports different sorts of plugins annotated using the @Plugin annotation.
E.g., if you want to have a bunch of different "image transform" plugins
you could make an interface ImageTransform which extends ImageJPlugin and
then write "@Plugin(type = ImageTransform.class)" in front of each such
plugin. Then the SciJava/ImageJ2 PluginService will automatically be aware
of all such plugins on the classpath, and you can query them at runtime.

Regards,
Curtis

[1] https://gist.github.com/ctrueden/3a68759c61dfeaa91a26

On Fri, Feb 20, 2015 at 8:43 AM, Thorsten Wagner <
[hidden email]> wrote:

> Dear list,
>
> I wondering if it is possible to scan all available plugins if they are
> implementing a specific class.
>
> Any ideas?
>
> Cheers,
> Thorsten
>
> --
> ImageJ mailing list: http://imagej.nih.gov/ij/list.html
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Find plugins which are extending a specifc class

jumpfunky
This is exactly what I want. Thank you curtis!

Cheers,
Thorsten

> if you want to have a bunch of different "image transform" plugins you
> could make an interface ImageTransform which extends ImageJPlugin and
> then write "@Plugin(type = ImageTransform.class)" in front of each
> such plugin. Then the SciJava/ImageJ2 PluginService will automatically
> be aware of all such plugins on the classpath, and you can query them
> at runtime.
>

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html