Class AutoShutdown
AWT's AWTAutoShutdown at session scope: the app ends —
session.close() — when its last displayable Window is
disposed and nothing holds it open (D_auto_shutdown). Four seams, wired into
the call graph rather than called as an API:
AutoShutdown.enableForApp(session); // @MainWindow JFrame ctor: this session is an app
AutoShutdown.armFromUndisplayable(); // Window.dispose -> removeNotify: it may be over
AutoShutdown.holdOpen(session, timer); // a started Timer: not over yet
AutoShutdown.checkAppOver(session); // the callSwing epilogue: decide
The decision lands in that epilogue because it is AWT's idle-EDT analogue:
the envelope's access-queue drain has run, so a dispose();
invokeLater(() -> new MainFrame()) handoff already has its new window up.
Every method must be called with the session lock held — each one reads or writes a session attribute.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidenableForApp(com.vaadin.flow.server.VaadinSession session) Declares this session a running app, which is what puts it in scope for auto-shutdown at all — nothing arms before it.static voidRegisterstokenas something that keeps the app alive with no window of its own — AWT's "busy" marker, whose one holder today is a startedTimer.static voidreleaseHold(com.vaadin.flow.server.VaadinSession session, Object token) Dropstoken's hold; idempotent.
-
Method Details
-
enableForApp
public static void enableForApp(com.vaadin.flow.server.VaadinSession session) Declares this session a running app, which is what puts it in scope for auto-shutdown at all — nothing arms before it.A host that never started an app — a Sampler route, a test popping a bare
JDialog— has no program lifetime to end, so the@MainWindowframe is the anchor and every other host stays out (D_auto_shutdown). Idempotent, F5 included. -
holdOpen
Registerstokenas something that keeps the app alive with no window of its own — AWT's "busy" marker, whose one holder today is a startedTimer.- Parameters:
token- retained strongly untilreleaseHold(VaadinSession, Object), as the JDK'sTimerQueueretains a started Timer — which is why one keeps the JVM alive there. Bounded by the session, not the process.
-
releaseHold
-