[ImageJ-devel] [fiji-devel] creating io.scif.img.ImgOpener currently fails in Fiji
Tobias Pietzsch
pietzsch at mpi-cbg.de
Fri Aug 22 09:35:53 CDT 2014
Hi Johannes,
On 22 Aug 2014, at 09:04, Johannes Schindelin <Johannes.Schindelin at gmx.de> wrote:
> Hi Tobias,
>
> On Fri, 22 Aug 2014, Tobias Pietzsch wrote:
>
>> Currently
>> new io.scif.img.ImgOpener();
>> fails with
>> java.lang.IllegalArgumentException: Invalid service: net.imagej.legacy.LegacyAppEventService
>
> Yep, the explanation is very easy:
>
>> [...]
>> Caused by: java.lang.UnsupportedOperationException: Cannot instantiate more than one DefaultLegacyService
>> […]
I missed that...
>
> There is already a context, including a legacy service. Unfortunately, the
> best way to get at this context from an *ImageJ 1.x plugin* that I could
> come up with is:
>
> import org.scijava.Context;
>
> ...
>
> final Context context = (Context)
> IJ.runPlugIn(Context.class.getName(), "");
> final ImgOpener opener = new ImgOpener(context);
>
> (There is no way to make that more convenient without letting SCIFIO
> depend on ImageJ 1.x, which is of course a big no-no).
The problem with this solution you suggested is that it does not work in Eclipse:
Exception in thread "main" java.lang.IllegalArgumentException: Invalid service: net.imagej.legacy.DefaultLegacyService
As much as I understand the need for the runtime service discovery used by the scijava stack, there are certainly downsides to it.
My feeling is that in some ways it undermines the advantages that we have gained by switching to maven.
I can import a maven project into my Eclipse, and all the dependencies are there, explicitly and automatically, which is really very convenient.
Except now all dependencies are not there anymore because now there are non-obvious (to me) implicit runtime dependencies.
I find this unfortunate.
That being said, I found a solution that works for now, both in Eclipse and in Fiji
final ImgOpener opener = new ImgOpener( new Context( SCIFIOService.class, AppService.class, StatusService.class ) );
This avoids requiring the net.imagej.legacy.LegacyAppEventService.
It seems to work, but I’m not sure: Are there any downsides to that?
best regards,
Tobias
>
> Of course, you could also turn your plugin into an ImageJ2 plugin -- which
> is handled properly in Fiji thanks to Fiji Just Being ImageJ2 -- and then
> it would become as easy as:
>
> @Parameter
> private IOService io;
>
> ...
> // use the IOService (which lets SCIFIO handle
> // things) to open your dataset
>
> Ciao,
> Johannes
>
> --
> --
> Please avoid top-posting, and please make sure to reply-to-all!
>
> Mailing list web interface: http://groups.google.com/group/fiji-devel
>
> ---
> You received this message because you are subscribed to the Google Groups "Fiji-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to fiji-devel+unsubscribe at googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20140822/2a6139ab/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 455 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://imagej.net/pipermail/imagej-devel/attachments/20140822/2a6139ab/attachment.pgp>
More information about the ImageJ-devel
mailing list