Package jmri

Interface ShutDownTask

  • All Superinterfaces:
    java.util.concurrent.Callable<java.lang.Boolean>, java.util.EventListener, java.beans.PropertyChangeListener, java.lang.Runnable
    All Known Implementing Classes:
    AbstractShutDownTask, CbusEventTableShutdownTask, SwingShutDownTask, WarrantShutdownTask

    public interface ShutDownTask
    extends java.util.concurrent.Callable<java.lang.Boolean>, java.lang.Runnable, java.beans.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

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      java.lang.Boolean call()
      Ask if shut down is allowed.
      java.lang.String getName()
      Name to be provided to the user when information about this task is presented.
      void run()
      Take the necessary action.
      default void runEarly()
      Take the necessary action.
      • Methods inherited from interface java.beans.PropertyChangeListener

        propertyChange
    • Method Detail

      • call

        java.lang.Boolean call()
                        throws java.lang.Exception
        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 java.util.concurrent.Callable<java.lang.Boolean>
        Returns:
        true if it is OK to shut down, false to abort shut down.
        Throws:
        java.lang.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 java.lang.Runnable
      • getName

        java.lang.String getName()
        Name to be provided to the user when information about this task is presented.
        Returns:
        the name