Package com.nomagic.task
Class Task
- java.lang.Object
-
- com.nomagic.task.SwingWorker<java.lang.Object>
-
- com.nomagic.task.Task
-
- Direct Known Subclasses:
TeamworkService.AutoLoginTask
,TeamworkService.LoginTask
@OpenApi public abstract class Task extends com.nomagic.task.SwingWorker<java.lang.Object>
Task for execution of some code on a separate thread.
-
-
Field Summary
Fields Modifier and Type Field Description private boolean
cancelable
static java.lang.String
CANCELED
static java.lang.String
COMPLETED
private static java.util.concurrent.atomic.AtomicInteger
currentRunningCount
private static java.lang.ThreadLocal<ProgressStatus>
currentTaskStatus
private com.nomagic.task.Task.DoFinishedExecuter
doFinishedExecuter
static java.lang.String
EXCEPTION
private java.lang.Throwable[]
exceptions
private boolean
finished
static java.lang.String
FINISHED
private boolean
interruptThreadOnCancel
static java.lang.String
READY
private java.lang.String
state
static java.lang.String
STATE_CHANGED_PROPERTY
private java.beans.PropertyChangeSupport
stateChangeSupport
Register listeners to report task changeprivate ProgressStatus
status
static java.lang.String
WORKING
-
Constructor Summary
Constructors Constructor Description Task(java.lang.String name)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addPropertyChangedListener(java.beans.PropertyChangeListener listener)
java.lang.Object
construct()
static ProgressStatus
currentTaskStatus()
Returns currently activeTask
progress statusvoid
doFinished()
abstract void
execute()
private void
firePropertyChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
Fires property change event by given parametersjava.lang.Throwable
getException()
java.lang.String
getName()
java.lang.String
getState()
ProgressStatus
getStatus()
void
interrupt()
Sets state to CANCELED.void
interruptAndStop()
Deprecated.See MDUML-57069 for deprecationstatic boolean
isActiveTasks()
boolean
isCancelable()
boolean
isCanceled()
boolean
isCompleted()
boolean
isException()
boolean
isFinished()
boolean
isReady()
boolean
isWorking()
private static void
registerTask()
void
removePropertyChangedListener(java.beans.PropertyChangeListener listener)
void
setCancelable(boolean cancelable)
void
setDoFinishedExecuter(com.nomagic.task.Task.DoFinishedExecuter doFinishedExecuter)
void
setException(java.lang.Throwable e)
void
setFinished(boolean finished)
void
setInterruptThreadOnCancel(boolean interruptThreadOnCancel)
void
setName(java.lang.String name)
void
setState(java.lang.String state)
void
setStatus(ProgressStatus status)
void
stopTask()
Interrupt task and wait while it is workingprivate static void
unregisterTask()
-
-
-
Field Detail
-
STATE_CHANGED_PROPERTY
public static final java.lang.String STATE_CHANGED_PROPERTY
- See Also:
- Constant Field Values
-
currentRunningCount
private static final java.util.concurrent.atomic.AtomicInteger currentRunningCount
-
CANCELED
public static final java.lang.String CANCELED
- See Also:
- Constant Field Values
-
FINISHED
public static final java.lang.String FINISHED
- See Also:
- Constant Field Values
-
COMPLETED
public static final java.lang.String COMPLETED
- See Also:
- Constant Field Values
-
WORKING
public static final java.lang.String WORKING
- See Also:
- Constant Field Values
-
READY
public static final java.lang.String READY
- See Also:
- Constant Field Values
-
EXCEPTION
public static final java.lang.String EXCEPTION
- See Also:
- Constant Field Values
-
currentTaskStatus
private static final java.lang.ThreadLocal<ProgressStatus> currentTaskStatus
-
status
private ProgressStatus status
-
state
private java.lang.String state
-
exceptions
private final java.lang.Throwable[] exceptions
-
cancelable
private boolean cancelable
-
finished
private volatile boolean finished
-
interruptThreadOnCancel
private boolean interruptThreadOnCancel
-
doFinishedExecuter
private com.nomagic.task.Task.DoFinishedExecuter doFinishedExecuter
-
stateChangeSupport
private java.beans.PropertyChangeSupport stateChangeSupport
Register listeners to report task change
-
-
Method Detail
-
setInterruptThreadOnCancel
public void setInterruptThreadOnCancel(boolean interruptThreadOnCancel)
-
currentTaskStatus
public static ProgressStatus currentTaskStatus()
Returns currently activeTask
progress status- Returns:
- currently active
Task
progress status ornull
if current thread is not executing aTask
-
setName
public void setName(java.lang.String name)
-
setException
public void setException(@CheckForNull java.lang.Throwable e)
-
getException
public java.lang.Throwable getException()
-
getName
public java.lang.String getName()
-
getStatus
public ProgressStatus getStatus()
-
setStatus
public void setStatus(ProgressStatus status)
-
isCompleted
public boolean isCompleted()
-
isWorking
public boolean isWorking()
-
isReady
public boolean isReady()
-
isException
public boolean isException()
-
isCanceled
public boolean isCanceled()
-
unregisterTask
private static void unregisterTask()
-
setState
public void setState(java.lang.String state)
-
firePropertyChange
private void firePropertyChange(java.lang.String name, java.lang.Object oldValue, java.lang.Object newValue)
Fires property change event by given parameters- Parameters:
name
- property nameoldValue
- old property valuenewValue
- new property value
-
getState
public java.lang.String getState()
-
construct
@CheckForNull public final java.lang.Object construct()
- Specified by:
construct
in classcom.nomagic.task.SwingWorker<java.lang.Object>
-
registerTask
private static void registerTask()
-
execute
public abstract void execute() throws java.lang.Exception
- Throws:
java.lang.Exception
-
interruptAndStop
@Deprecated public final void interruptAndStop()
Deprecated.See MDUML-57069 for deprecation- Overrides:
interruptAndStop
in classcom.nomagic.task.SwingWorker<java.lang.Object>
-
doFinished
public final void doFinished()
- Overrides:
doFinished
in classcom.nomagic.task.SwingWorker<java.lang.Object>
-
isFinished
public boolean isFinished()
- Returns:
- true if task is completely finished (execute and finished methods are executed)
-
isCancelable
public boolean isCancelable()
- Returns:
- Returns the cancelable.
-
setCancelable
public void setCancelable(boolean cancelable)
- Parameters:
cancelable
- The cancelable to set.
-
interrupt
public void interrupt()
Sets state to CANCELED. Notifies all threads that are waiting on this object monitor.- Overrides:
interrupt
in classcom.nomagic.task.SwingWorker<java.lang.Object>
-
isActiveTasks
public static boolean isActiveTasks()
-
addPropertyChangedListener
public void addPropertyChangedListener(java.beans.PropertyChangeListener listener)
-
removePropertyChangedListener
public void removePropertyChangedListener(java.beans.PropertyChangeListener listener)
-
setFinished
public void setFinished(boolean finished)
-
setDoFinishedExecuter
public void setDoFinishedExecuter(com.nomagic.task.Task.DoFinishedExecuter doFinishedExecuter)
-
stopTask
public void stopTask()
Interrupt task and wait while it is working
-
-