Making a list of the availabe plugins and call them (in execution time)

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

Making a list of the availabe plugins and call them (in execution time)

roger.sama
Hello guys,

I've search for a topic about this subject but haven't found anything that help me.

I want to list the available plugins and call them (a specific static method) in execution time. I'm developping a kind of testing tool and I need the user to select the plugin that he wants to test.

Can anyone help me?

Thanks for the time,

Roger
Reply | Threaded
Open this post in threaded view
|

Re: Making a list of the availabe plugins and call them (in execution time)

dscho
Hi Roger,

On Mon, 1 Jun 2009, roger.sama wrote:

> I want to list the available plugins

We have some code in Fiji (written as a Jython script) that does exactly
that.

> and call them (a specific static method) in execution time.

I do not understand: do you assume that the plugins have that static
method?  They don't...

> I'm developping a kind of testing tool and I need the user to select the
> plugin that he wants to test.

Unfortunately, this will not work.  Plugins are too diverse to develop a
generic testing framework.

Unless, of course, you record a macro of everything the user does (which
gets tricky in and of itself) and the full input/output images (which will
be a bit expensive with some of the plugins we have in Fiji).

Ciao,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: Making a list of the availabe plugins and call them (in execution time)

Michael Schmid
In reply to this post by roger.sama
Hi Roger,

maybe one need not see it as strict as Johannes:

For inspirations, have a look at the run method CommandFinder code,
   http://rsb.info.nih.gov/ij/source/ij/plugin/CommandFinder.java

   Hashtable realCommandsHash = ij.Menus.getCommands();

Here you get all commands; skip those that are internal comands (hash  
value, i.e., name of the method starting with "ij.")

A clean way would be defining an interface with the static method and  
all your plugins implementing that interface.

Otherwise, you will need 'reflection' to check whether the plugin  
class has the method that you want to call, then use 'invoke':

http://java.sun.com/j2se/1.4.2/docs/api/java/lang/ 
Class.html#getDeclaredMethod(java.lang.String,%20java.lang.Class[])
http://java.sun.com/j2se/1.4.2/docs/api/java/lang/reflect/ 
Method.html#invoke(java.lang.Object,%20java.lang.Object[])


Michael
________________________________________________________________

On 2 Jun 2009, at 04:31, roger.sama wrote:

> Hello guys,
>
> I've search for a topic about this subject but haven't found  
> anything that
> help me.
>
> I want to list the available plugins and call them (a specific static
> method) in execution time. I'm developping a kind of testing tool  
> and I need
> the user to select the plugin that he wants to test.
>
> Can anyone help me?=^D
>
> Thanks for the time,
>
> Roger
>
Reply | Threaded
Open this post in threaded view
|

Re: Making a list of the availabe plugins and call them (in execution time)

roger.sama
In reply to this post by roger.sama
Thank you guys for your response.

I assume that the "testable" plugins follow an architecture that was defined in the project, so all of them will have that static method that I told about it.

I was able to solve the problem by using Java reflexion with the classes Methods and Class. Thanks again for yout attetion. o/

Roger