Class AutoShutdown

java.lang.Object
vaadinx.AutoShutdown

public final class AutoShutdown extends Object
INTERNAL — do not use. Not part of the emulated Swing API surface and has no stability guarantee; the signature exists only to serve emulator internals and may change without notice.

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 Type
    Method
    Description
    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.
    static void
    holdOpen(com.vaadin.flow.server.VaadinSession session, Object token)
    Registers token as something that keeps the app alive with no window of its own — AWT's "busy" marker, whose one holder today is a started Timer.
    static void
    releaseHold(com.vaadin.flow.server.VaadinSession session, Object token)
    Drops token's hold; idempotent.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 @MainWindow frame is the anchor and every other host stays out (D_auto_shutdown). Idempotent, F5 included.

    • holdOpen

      public static void holdOpen(com.vaadin.flow.server.VaadinSession session, Object token)
      Registers token as something that keeps the app alive with no window of its own — AWT's "busy" marker, whose one holder today is a started Timer.
      Parameters:
      token - retained strongly until releaseHold(VaadinSession, Object), as the JDK's TimerQueue retains a started Timer — which is why one keeps the JVM alive there. Bounded by the session, not the process.
    • releaseHold

      public static void releaseHold(com.vaadin.flow.server.VaadinSession session, Object token)
      Drops token's hold; idempotent.