Package jmri.implementation
Class AbstractShutDownTask
- java.lang.Object
-
- jmri.implementation.AbstractShutDownTask
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.lang.Runnable
,java.util.concurrent.Callable<java.lang.Boolean>
,java.util.EventListener
,ShutDownTask
- Direct Known Subclasses:
CbusEventTableShutdownTask
,DispatcherShutDownTask
,SwingShutDownTask
,WarrantShutdownTask
public abstract class AbstractShutDownTask extends java.lang.Object implements ShutDownTask
Abstract ShutDownTask implementation.This implementation provides a "doRun" property with a protected getter and setter to allow subclasses to set the "doRun" property to true inside
call()
so that the property can be checked insideShutDownTask.run()
to determine if anything should be done during shut down.
-
-
Constructor Summary
Constructors Constructor Description AbstractShutDownTask(java.lang.String name)
Constructor specifies the name
-
Method Summary
All Methods Instance Methods Concrete 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.boolean
isDoRun()
Check if action should be taken inShutDownTask.run()
method.void
propertyChange(java.beans.PropertyChangeEvent evt)
Note that overriding implementations should call this implementation to set the doRun property correctly.void
setDoRun(boolean flag)
Set if action should be taken inShutDownTask.run()
method.java.lang.String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jmri.ShutDownTask
run, runEarly
-
-
-
-
Constructor Detail
-
AbstractShutDownTask
public AbstractShutDownTask(java.lang.String name)
Constructor specifies the name- Parameters:
name
- Name to give this task
-
-
Method Detail
-
call
public java.lang.Boolean 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
ShutDownTask.run()
on the tasks.If this method returns false on any task, the shut down process must be aborted. This implementation merely sets the "doRun" property to true, and should be overridden for any real checking. Note that overriding implementations should call
setDoRun(boolean)
correctly.- Specified by:
call
in interfacejava.util.concurrent.Callable<java.lang.Boolean>
- Specified by:
call
in interfaceShutDownTask
- Returns:
- true if it is OK to shut down, false to abort shut down.
-
getName
public java.lang.String getName()
Description copied from interface:ShutDownTask
Name to be provided to the user when information about this task is presented.- Specified by:
getName
in interfaceShutDownTask
- Returns:
- the name
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
propertyChange
@OverridingMethodsMustInvokeSuper public void propertyChange(java.beans.PropertyChangeEvent evt)
Note that overriding implementations should call this implementation to set the doRun property correctly.- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
-
isDoRun
public boolean isDoRun()
Check if action should be taken inShutDownTask.run()
method. This defaults to false, although the default implementation ofcall()
sets this to true.- Returns:
- true if action should be taken; false otherwise
-
setDoRun
public void setDoRun(boolean flag)
Set if action should be taken inShutDownTask.run()
method. Overriding implementations ofcall()
must call this to setisDoRun()
to true.- Parameters:
flag
- true if action should be taken; false otherwise
-
-