Package jmri

Interface ShutDownTask

All Superinterfaces:
Callable<Boolean>, EventListener, PropertyChangeListener, Runnable
All Known Implementing Classes:
AbstractShutDownTask, CbusEventTableShutdownTask, DispatcherShutDownTask, SwingShutDownTask, WarrantShutdownTask

Execute a specific task before the program terminates.

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

A ShutDownTask can listen to the "shuttingDown" property of the ShutDownManager to determine if any other ShutDownTask aborted the shutdown; the property will change from false to true in that case.

  • Method Summary

    Modifier and Type
    Method
    Description
    Ask if shut down is allowed.
    Name to be provided to the user when information about this task is presented.
    void
    run()
    Take the necessary action.
    default void
    Take the necessary action.

    Methods inherited from interface java.beans.PropertyChangeListener

    propertyChange
  • Method Details

    • call

      Ask if shut down is allowed.

      The shut down manager calls this method first on all the tasks before starting to execute the method run() on the tasks.

      If this method returns false on any task, the shut down process must be aborted.

      Specified by:
      call in interface Callable<Boolean>
      Returns:
      true if it is OK to shut down, false to abort shut down.
      Throws:
      Exception - if there is an exception
    • runEarly

      default void runEarly()
      Take the necessary action. This method cannot abort the shutdown, and must not require user interaction to complete successfully. This method will be run in parallel to other ShutDownTasks, but will be executed before any of the run() methods are executed.
    • run

      void run()
      Take the necessary action. This method cannot abort the shutdown, and must not require user interaction to complete successfully. This method will be run in parallel to other ShutDownTasks.
      Specified by:
      run in interface Runnable
    • getName

      Name to be provided to the user when information about this task is presented.
      Returns:
      the name