[ImageJ-devel] external plugins
Mark Hiner
hiner at wisc.edu
Thu Mar 19 08:51:05 CDT 2015
Hi Jay,
>One of the main things I can't quite envision is how to process the
annotations of an external .java file at runtime so that I can utilize that
information
You shouldn't have to do this yourself. By using the SciJava plugin
framework you get discovery of all annotated plugins on your classpath, and
processing/indexing of those plugins, for free.
I'm assuming the paradigm that would match your needs is a
HandlerService[1]. The service would perform some function (e.g. opening a
path) and the behavior of that function would be extensible via
HandlerPlugins[2] (e.g. a plugin for handling URLs, files on disk, files in
a database, etc...).
The simplest example of "service chooses a plugin appropriate for the
circumstances" is the AnimalService tutorial[3]. Note that it's not
actually a HandlerService but could easily be converted to one. More
complex examples would be the IOService[4] or SCIFIO's FormatService[5].
Best,
Mark
[1]
https://github.com/scijava/scijava-common/blob/scijava-common-2.39.0/src/main/java/org/scijava/plugin/HandlerService.java
[2]
https://github.com/scijava/scijava-common/blob/scijava-common-2.39.0/src/main/java/org/scijava/plugin/HandlerPlugin.java
[3]
https://github.com/imagej/imagej-tutorials/tree/00394f9f5010d1787b9bf584b6e90eed01beec0d/create-a-new-plugin-type/src/main/java
[4]
https://github.com/scijava/scijava-common/blob/scijava-common-2.39.0/src/main/java/org/scijava/io/IOService.java
[5]
https://github.com/scifio/scifio/blob/scifio-0.21.1/src/main/java/io/scif/services/FormatService.java
On Wed, Mar 18, 2015 at 6:42 PM, Jay Warrick <jay.w.warrick at gmail.com>
wrote:
> Hi All,
>
> I am using the scijava plugin framework, ImageJ2, and its Plugin service.
> I would like to allow other people to write a plugin for my software. I'm
> open to suggestions but I'd probably like to enable them to place their
> java/jar/class plugin file in a folder, and I could look into that folder
> to load their plugin. I'm thinking along the lines of how how old ImageJ
> did things. Does anyone have suggestions or example code (e.g., in FIJI
> somewhere) for loading/compiling such plugin files during runtime. One of
> the main things I can't quite envision is how to process the annotations of
> an external .java file at runtime so that I can utilize that information
> (e.g., in conjunction with the PluginService). If there is an inherent
> problem in what I'm hoping to do, please let me know :-) (e.g., if I am
> provided compiled code, I suspect I might need an annotation index to go
> with it if I need that information).
>
> I figured you guys have tackled this problem thoroughly already and thus
> would be a good resource. Thanks in advance!
>
> Regards,
>
> Jay
>
>
> _______________________________________________
> ImageJ-devel mailing list
> ImageJ-devel at imagej.net
> http://imagej.net/mailman/listinfo/imagej-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20150319/9eec5460/attachment.html>
More information about the ImageJ-devel
mailing list