public class DefaultTaskMonitor extends Object implements TaskMonitor
TaskMonitor
reference implementation.
The reference implementation uses a thread checking the state of all tasks
in the system periodically which is started upon initialization and runs
endlessly. Monitoring is controlled by property pollIntervalMillis
specifying the milliseconds of one period. Each time a period ends, tasks
are checked for state changes and corresponding events are fired. Property
pollIntervalMillis
defaults to 250ms
.
Note:
TaskEvent
s of type STARTED
and ENDED
are fired by the
thread executing the task's operation. Since tasks are monitored
asynchronously, TaskEvent
s of type CHANGED_STATE
are fired by
the monitor thread, not by the thread executing the task's operation. Make
sure TaskListener
implementations are prepared for being notified
by a different thread than the one executing a task's operation.
Container
Constructor and Description |
---|
DefaultTaskMonitor()
Standard implementation constructor
org.jdtaus.core.monitor.ri.DefaultTaskMonitor . |
DefaultTaskMonitor(long pollIntervalMillis)
Creates a new
DefaultTaskMonitor instance taking the
milliseconds of one period. |
Modifier and Type | Method and Description |
---|---|
void |
addTaskListener(org.jdtaus.core.monitor.TaskListener listener) |
void |
finish(org.jdtaus.core.monitor.Task task) |
org.jdtaus.core.monitor.TaskListener[] |
getTaskListeners() |
void |
monitor(org.jdtaus.core.monitor.Task task) |
void |
removeTaskListener(org.jdtaus.core.monitor.TaskListener listener) |
public DefaultTaskMonitor()
org.jdtaus.core.monitor.ri.DefaultTaskMonitor
.public DefaultTaskMonitor(long pollIntervalMillis)
DefaultTaskMonitor
instance taking the
milliseconds of one period.pollIntervalMillis
- the number of milliseconds per poll interval.public void addTaskListener(org.jdtaus.core.monitor.TaskListener listener)
addTaskListener
in interface org.jdtaus.core.monitor.TaskEventSource
public void finish(org.jdtaus.core.monitor.Task task)
finish
in interface TaskMonitor
public org.jdtaus.core.monitor.TaskListener[] getTaskListeners()
getTaskListeners
in interface org.jdtaus.core.monitor.TaskEventSource
public void monitor(org.jdtaus.core.monitor.Task task)
monitor
in interface TaskMonitor
public void removeTaskListener(org.jdtaus.core.monitor.TaskListener listener)
removeTaskListener
in interface org.jdtaus.core.monitor.TaskEventSource
Copyright © 2005-2012 jDTAUS. All Rights Reserved.