public class DefaultTaskContext extends Object implements TaskContext, PropertyChangeListener
Task
which is governed by a DefaultTaskWorker
. This context holds
adds listener support. It registers itself as PropertyChangeListener
to the DefaultTaskWorker
object and translates the UIThreadWorker
events to TaskEvent
s.
Each execution can be identified by a growing id. For retrieving task execution properties it delegates
to the wrapped DefaultTaskWorker
.Constructor and Description |
---|
DefaultTaskContext(TaskWorker worker,
TaskListenerSupport taskListenerSupport) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(TaskListener listener)
Adds listener that receives events for this execution only.
|
boolean |
equals(Object o) |
void |
firePhaseChangeEvent(String oldValue,
String newValue) |
void |
fireProgressChangeEvent(Integer oldValue,
Integer newValue) |
void |
fireStateChangeEvent(Task.State oldValue,
Task.State newValue) |
String |
getContextId()
The context id is generated on each task execution and
is (at least) unique among all executions in this application
run.
|
Long |
getDuration() |
Long |
getFinishTimestamp() |
String |
getPhase() |
int |
getProgress() |
Long |
getStartedTimestamp() |
Task.State |
getState() |
Task |
getTask() |
<V,C> TaskWorker<V,C> |
getWorker() |
int |
hashCode() |
void |
propertyChange(PropertyChangeEvent evt) |
void |
removeListener(TaskListener listener) |
String |
toString() |
public DefaultTaskContext(TaskWorker worker, TaskListenerSupport taskListenerSupport)
public String getContextId()
TaskContext
getContextId
in interface TaskContext
public Long getStartedTimestamp()
getStartedTimestamp
in interface TaskContext
public Long getFinishTimestamp()
getFinishTimestamp
in interface TaskContext
public Task.State getState()
getState
in interface TaskContext
public int getProgress()
getProgress
in interface TaskContext
public String getPhase()
getPhase
in interface TaskContext
public Long getDuration()
getDuration
in interface TaskContext
public void addListener(TaskListener listener)
TaskContext
TaskListenerSupport
to add more global listeners.addListener
in interface TaskContext
public void removeListener(TaskListener listener)
removeListener
in interface TaskContext
public <V,C> TaskWorker<V,C> getWorker()
getWorker
in interface TaskContext
public Task getTask()
getTask
in interface TaskContext
public void fireStateChangeEvent(Task.State oldValue, Task.State newValue)
fireStateChangeEvent
in interface TaskContext
public void fireProgressChangeEvent(Integer oldValue, Integer newValue)
fireProgressChangeEvent
in interface TaskContext
public void firePhaseChangeEvent(String oldValue, String newValue)
firePhaseChangeEvent
in interface TaskContext
public void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener