Skip to content
This repository has been archived by the owner on May 26, 2018. It is now read-only.

Delay initialization #2

Merged
merged 4 commits into from
May 10, 2014
Merged

Delay initialization #2

merged 4 commits into from
May 10, 2014

Conversation

ctrueden
Copy link
Member

@ctrueden ctrueden commented May 9, 2014

We want to delay initialization of the DefaultFijiService until after the LegacyService has initialized (and hence set up ImageJ1 as desired, including patches). But we cannot add a direct dependency on LegacyService via the usual @Parameter mechanism because that would hose the class loading process. So let's make DefaultFijiService initialize itself very late in the game.

Let's not redirect stdout and stderr, and let's not refresh the menus,
unless ImageJ1 has been initialized first.
What we really want is to initialize *after* the LegacyService has
initialized. The normal way to accomplish this would be to add an
@parameter on the LegacyService, which would force that service to be
initialized first. Unfortunately, by doing that, we force the class
loader to load the LegacyService prematurely, hosing everything.

So the hacky solution we employ here is instead to listen for when
context creation is totally complete (signified by the
ServicesLoadedEvent being fired), and *then* finally initialize the
DefaultFijiService. We do it this way, rather than a lazy initialization
scheme, because we *do* want the DefaultFijiService to initialize right
away rather than only in response to some API call later.
dscho added a commit that referenced this pull request May 10, 2014
@dscho dscho merged commit 3dc8f9c into master May 10, 2014
@dscho dscho deleted the delay-initialize branch May 10, 2014 22:23
@dscho
Copy link
Contributor

dscho commented May 10, 2014

Thanks! We should probably upload a new fiji-compat.jar soon... Wednesday?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants