Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reinstate ImageJ 1.x' "single instance listener" #116

Merged
merged 8 commits into from
Jun 30, 2015

Conversation

dscho
Copy link
Contributor

@dscho dscho commented Jun 30, 2015

In ImageJ 1.x, there is an option Options>Misc...>Run single instance listener; When checked, it tells ImageJ to look for an existing ImageJ instance when starting up, and passing the command-line options if one is found. Essentially, it makes ImageJ behave like a singleton.

This Pull Request reinstates that functionality and fixes a few issues related to it. The work has been sponsored by Zeiss Deutschland to ensure interoperability between Fiji and ZEN.

Unfortunately, it has to be static so that we can call
`subscribeEvents()` even before the LegacyService has been fully
initialized.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@ctrueden
Copy link
Member

Awesome that Zeiss sponsored this! 👍

All in all, looks pretty good. I made some minor comments. My more serious concern is that this feature was reintroduced completely at the ImageJ1 level in this imagej-legacy component, rather than being done purely as a SciJava feature. It would be a useful feature even if the ImageJ1 legacy layer is not present or enabled, but with the current implementation, would not be available in that scenario, which is a shame.

Perhaps someday it can be refactored to remove ImageJ1-isms from the core functionality, and migrated into SciJava Common where it belongs.

In the meantime, it gets the job done for Zeiss et. al, so if you address the small concerns I'll merge it.

They repeated code.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
In ImageJ1, there is an option in Options>Misc...>Run single instance
listener; When checked, it tells ImageJ1 to look for an existing ImageJ
instance when starting up, and passing the command-line options if one
is found.

We will reinstate that functionality in the next few commits and need to
prepare the IJ1Helper for that.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
The purpose of this class -- which we now call SingleInstance because it
is more appropriate -- is to start an Remote Method Invocation (RMI)
server when ImageJ is started, listening for commands being sent by
subsequent invocations of the ImageJ executable.

Essentially, it makes ImageJ a singleton, when that "Run single instance
listener" option is checked.

We still need to *use* this class, of course, which is the purpose of
the next commit.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This patch introduces a ConsoleService that overrides the default
console service so that we can quit when an ImageJ instance was detected
and the command line parameters have been handed off.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Due to recent changes in the `openImage()` method, images are not shown
when loaded as long as the UI is not shown. This is the case when images
are loaded as part of command line parameter parsing.

Let's force images to be shown when we know that the UI will be shown
eventually.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
ImageJ should be called in batch mode when run in a headless
environment, of course, but even if batch mode is off, we should not
show images when we're headless.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
We never know which ConsoleService has the next lower priority,
until we ask the ServiceIndex. So we model the consoleService() method
after SCIFIO's DatasetService strategy.

Pointed out by Curtis Rueden.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
@dscho
Copy link
Contributor Author

dscho commented Jun 30, 2015

Updated PR.

ctrueden added a commit that referenced this pull request Jun 30, 2015
Reinstate ImageJ 1.x' "single instance listener"
@ctrueden ctrueden merged commit e355082 into master Jun 30, 2015
@ctrueden ctrueden deleted the single-instance-listener branch June 30, 2015 20:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants