Login  Register

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

Posted by Michael Schmid on Jun 02, 2009; 10:38am
URL: http://imagej.273.s1.nabble.com/Making-a-list-of-the-availabe-plugins-and-call-them-in-execution-time-tp3692323p3692325.html

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
>