Package jmri

Interface ShutDownManager

All Superinterfaces:
PropertyChangeProvider
All Known Implementing Classes:
DefaultShutDownManager

public interface ShutDownManager extends PropertyChangeProvider
Manage tasks to be completed when the program shuts down normally.

Implementations of this interface allow other objects to register and deregister ShutDownTask objects, which are invoked in an orderly way when the program is is commanded to terminate. There is no requirement a ShutDownTask not interact with the user interface, and an assumption that, barring a headless application, that ShutDownTasks may interact with the user interface.

There can only be one instance of this operating, and it is generally obtained via the instance manager.

ShutDownTasks should leave the system in a state that can continue, in case a later task aborts the shutdown.

An instance of this is normally obtained from the instance manager, using may assume that one is always present.

  • Method Details

    • register

      Register a task object for later execution. An attempt to register an already registered task will be silently ignored.
      Parameters:
      task - the task to execute
      Throws:
      NullPointerException - if the task is null
    • register

      Register a task for verification that JMRI should stop. An attempt to register an already register task will be silently ignored.
      Parameters:
      task - the verification task
      Throws:
      NullPointerException - if the task is null
    • register

      Register a task that runs when JMRI is stopping. An attempt to register an already register task will be silently ignored.
      Parameters:
      task - the execution task
      Throws:
      NullPointerException - if the task is null
    • deregister

      Deregister a task. Attempts to deregister a task that is not registered are silently ignored.
      Parameters:
      task - the task not to execute
    • deregister

      Deregister a task. Attempts to deregister a task that is not registered are silently ignored.
      Parameters:
      task - the task not to call
    • deregister

      Deregister a task. Attempts to deregister a task that is not registered are silently ignored.
      Parameters:
      task - the task not to run
    • getCallables

    • getRunnables

    • restartOS

      void restartOS()
      Run the shutdown tasks, and then terminate the program with status 210 if not aborted. Does not return under normal circumstances. Returns false if the shutdown was aborted by the user, in which case the program should continue to operate.

      By exiting the program with status 210, the batch file (MS Windows) or shell script (Linux/macOS/UNIX) can catch the exit status and tell the operating system to restart.

    • restart

      void restart()
      Run the shutdown tasks, and then terminate the program with status 100 if not aborted. Does not return under normal circumstances. Returns false if the shutdown was aborted by the user, in which case the program should continue to operate.

      By exiting the program with status 100, the batch file (MS Windows) or shell script (Linux/macOS/UNIX) can catch the exit status and restart the JMRI java program.

    • shutdownOS

      void shutdownOS()
      Run the shutdown tasks, and then terminate the program with status 200 if not aborted. Does not return under normal circumstances. Returns false if the shutdown was aborted by the user, in which case the program should continue to operate.

      By exiting the program with status 200, the batch file (MS Windows) or shell script (Linux/macOS/UNIX) can catch the exit status and shutdown the OS

    • shutdown

      void shutdown()
      Run the shutdown tasks, and then terminate the program with status 0 if not aborted. Does not return under normal circumstances. Returns false if the shutdown was aborted by the user, in which case the program should continue to operate.
    • isShuttingDown

      boolean isShuttingDown()
      Allow components that normally request confirmation to shutdown to determine if the shutdown is already underway so as not to request confirmation.
      Returns:
      true if shutting down or restarting