<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">Hi Johannes,<div><br></div><div>On 22 Aug 2014, at 09:04, Johannes Schindelin <<a href="mailto:Johannes.Schindelin@gmx.de">Johannes.Schindelin@gmx.de</a>> wrote:</div><div><div><br class="Apple-interchange-newline"><blockquote type="cite">Hi Tobias,<br><br>On Fri, 22 Aug 2014, Tobias Pietzsch wrote:<br><br><blockquote type="cite">Currently<br>new io.scif.img.ImgOpener();<br>fails with<br>java.lang.IllegalArgumentException: Invalid service: net.imagej.legacy.LegacyAppEventService<br></blockquote><br>Yep, the explanation is very easy:<br><br><blockquote type="cite">[...]<br>Caused by: java.lang.UnsupportedOperationException: Cannot instantiate more than one DefaultLegacyService<br>[…]<br></blockquote></blockquote><div><br></div><div>I missed that...</div><br><blockquote type="cite"><br>There is already a context, including a legacy service. Unfortunately, the<br>best way to get at this context from an *ImageJ 1.x plugin* that I could<br>come up with is:<br><br><span class="Apple-tab-span" style="white-space:pre"> </span>import org.scijava.Context;<br><br><span class="Apple-tab-span" style="white-space:pre"> </span>...<br><br><span class="Apple-tab-span" style="white-space:pre"> </span>final Context context = (Context)<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>IJ.runPlugIn(Context.class.getName(), "");<br><span class="Apple-tab-span" style="white-space:pre"> </span>final ImgOpener opener = new ImgOpener(context);<br><br>(There is no way to make that more convenient without letting SCIFIO<br>depend on ImageJ 1.x, which is of course a big no-no).<br></blockquote><div><br></div><div><div>The problem with this solution you suggested is that it does not work in Eclipse:</div><div><div style="margin: 0px; font-size: 11px; font-family: Monaco; color: rgb(255, 38, 0);">Exception in thread "main" <span style="text-decoration: underline ; color: #0433ff">java.lang.IllegalArgumentException</span>: Invalid service: net.imagej.legacy.DefaultLegacyService</div></div><div><br></div></div><div>As much as I understand the need for the runtime service discovery used by the scijava stack, there are certainly downsides to it.</div><div>My feeling is that in some ways it undermines the advantages that we have gained by switching to maven.</div><div>I can import a maven project into my Eclipse, and all the dependencies are there, explicitly and automatically, which is really very convenient.</div><div>Except now all dependencies are not there anymore because now there are non-obvious (to me) implicit runtime dependencies.</div><div>I find this unfortunate.</div><div><br></div><div>That being said, I found a solution that works for now, both in Eclipse and in Fiji</div><div> final ImgOpener opener = new ImgOpener( new Context( SCIFIOService.class, AppService.class, StatusService.class ) );</div><div><div>This avoids requiring the net.imagej.legacy.LegacyAppEventService.</div><div>It seems to work, but I’m not sure: Are there any downsides to that?</div><div><br></div><div>best regards,</div><div>Tobias</div><div><br></div></div><blockquote type="cite"><br>Of course, you could also turn your plugin into an ImageJ2 plugin -- which<br>is handled properly in Fiji thanks to Fiji Just Being ImageJ2 -- and then<br>it would become as easy as:<br><br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>@Parameter<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>private IOService io;<br><br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>...<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>// use the IOService (which lets SCIFIO handle<br><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span><span class="Apple-tab-span" style="white-space:pre"> </span>// things) to open your dataset<br><br>Ciao,<br>Johannes<br><br>-- <br>-- <br>Please avoid top-posting, and please make sure to reply-to-all!<br><br>Mailing list web interface: <a href="http://groups.google.com/group/fiji-devel">http://groups.google.com/group/fiji-devel</a><br><br>--- <br>You received this message because you are subscribed to the Google Groups "Fiji-devel" group.<br>To unsubscribe from this group and stop receiving emails from it, send an email to <a href="mailto:fiji-devel+unsubscribe@googlegroups.com">fiji-devel+unsubscribe@googlegroups.com</a>.<br>For more options, visit <a href="https://groups.google.com/d/optout">https://groups.google.com/d/optout</a>.<br></blockquote></div><br></div></body></html>