Package jmri

Interface ShutDownTask

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

public interface ShutDownTask
extends Callable<Boolean>, Runnable, PropertyChangeListener
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
    Boolean call()
    Ask if shut down is allowed.
    boolean execute()
    Deprecated.
    since 4.21.1; use run() instead
    String getName()
    Name to be provided to the user when information about this task is presented.
    boolean isComplete()
    Deprecated.
    since 4.21.1; this is ignored as all tasks are run in an independent Thread that is independently monitored
    boolean isParallel()
    Deprecated.
    since 4.21.1; this is ignored and all tasks are run in an independent Thread
    boolean isShutdownAllowed()
    Deprecated.
    since 4.21.1; use call() instead
    void run()
    Take the necessary action.

    Methods inherited from interface java.beans.PropertyChangeListener

    propertyChange
  • Method Details

    • isShutdownAllowed

      Deprecated.
      since 4.21.1; use call() instead
      Ask if shut down is allowed.

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

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

      Returns:
      true if it is OK to shut down, false to abort shut down.
    • 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
    • execute

      @Deprecated boolean execute()
      Deprecated.
      since 4.21.1; use run() instead
      Take the necessary action.

      If the task is lengthy and can easily confirm that it should proceed (i.e., prompt the user to save, not save, or cancel shutting down), and spin itself off into a new thread, it should do so.

      Note if a task is parallel, this method should return after any tests that might cause the shutdown to be aborted.

      Returns:
      true if the shutdown should continue, false to abort.
    • 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
    • isParallel

      Deprecated.
      since 4.21.1; this is ignored and all tasks are run in an independent Thread
      Advise ShutDownManagers if execute() may return before the task is complete.

      Note if a task is parallel, execute() should return after any tests that might cause the shutdown to be aborted.

      Returns:
      true if the task is run within its own Thread
    • isComplete

      Deprecated.
      since 4.21.1; this is ignored as all tasks are run in an independent Thread that is independently monitored
      Advise ShutDownManagers that the task is complete.
      Returns:
      true if the task is complete