Class AppInstance
static fields (M1D_former_singletons). A migrated app's holder
is one line over it:
public static FormerSingletons get() {
return AppInstance.get(FormerSingletons.class, FormerSingletons::new);
}
Values are created on first touch, shared by everything that app does,
reachable from everywhere that app runs — its WINDOW_CLOSING cleanup
included — and gone when the app is. They survive an F5 and die with the browser
tab.
UI-thread-confined, with one exception: get(Class, Supplier) also resolves on the
request-less teardown threads, where a session is current but no UI is.
The store is TabScope, kept private so it can change: "one
running app instance" maps 1:1 onto a browser tab only while SB-Emulators runs one app
per session (D_active_ui_pointer). Not inlined to TabScope.getCurrent().getValues() at
the call site, tempting as that looks — getCurrent() needs a current
UI, which D_shutdown_lifecycle shutdown does not have, so the inlined form throws in
exactly the handler that flushes caches and saves preferences. That is not an
upstream oversight to wait out: a session may hold several tab scopes and the
library cannot know which is the app. AppTab does, which is
why resolution lands here.
-
Method Summary
-
Method Details
-
get
The app instance's value of the given type, created byfactoryon first touch and returned as-is afterwards.- Parameters:
type- identity of the value within the app instancefactory- invoked at most once per app instance; must not returnnull- Returns:
- never
null - Throws:
IllegalStateException- from a background thread (SwingWorker.doInBackground, a rawThread), or before the app's tab scope is ready — astaticinitializer, or an app that never wiredSwingBridgeEmulatorsBootstrap. The message names the likely cause.
-