|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK 11g Release 2 (11.1.2.2.0) E17493-03 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
oracle.ide.task.TaskManager
public class TaskManager
The TaskManager is a singleton that controls and monitors the execution of all tasks The basic pattern is to create a Task or TaskGroup and hand it over to the TaskManager for execution. Here is a simple example
Task t=new Task(){ public TaskExitCode performTask(TaskRuntimeServices tc){ // this is where the client code is ... // tc.fireProgress(new TaskProgress(20,100,10); return TaskExitCode.COMPLETED; } } TaskListener tl=new TaskListener(){ public void taskCompleted(TaskEvent e){ // do something with this knowledge of task completion } public void taskException(TaskEvent e, Exception e){ // } .. } t.addTaskListener(tl); TaskManager.start(t);
* The tasks fire state change events, -for example 'taskCompleted(...) etc which are part of the TaskListener interface. A client must implement some class as TaskListener and then add it to the Task for which the callbacks are required. TaskGroups can be used in a similar manner.
TaskGroup taskGroup = new TaskGroup("StartupTaskGroup", TaskGroupExecutionPolicy.CONTINUE_ON_FAILURE); MyTask t1 = new MyTask("Task01"); taskGroup.addTask(t1); MyTask t2 = new MyTask("Task02"); taskGroup.addTask(t2); MyTask t3 = new MyTask("Task03"); taskGroup.addTask(t3); MyTask t4 = new MyTask("Task04"); taskGroup.addTask(t4); // taskGroup.addTaskListener(new SomeTaskGroupListener()); taskManager.startTask(taskGroup);
Note that the TaskListener that is attached to a TaskGroup will received cumulative updates from the TaskGroup, and this may not be discernible for indiviual task progress. If the progress of an individual task is required, a task listener should be attached to that specific task. Also note that TaskGroups require a TaskGroupExecutionPolicy to be specified. TaskGroups are Tasks, and thus can be schedueled or started in the same manner as Tasks.
Method Summary | |
---|---|
java.util.concurrent.Future<?> |
enqueueTask(Task task) |
protected static TaskID |
generateID() Internal method |
static TaskManager |
getInstance() Retrieves the singleton instance of the TaskManager |
static TaskMonitor |
getTaskMonitor(java.lang.String key) Sets the TaskMonitor object. |
TaskID |
scheduleTask(Task task, TaskLockRequest lock) NOT IMPLEMENTED When a Task requires locking of any resources, it must schedule the task and the task manager will run this task when possible without any lock contention. |
protected static void |
setTaskMonitor(java.lang.String key, TaskMonitor value) Sets the TaskMonitor object. |
TaskID |
startTask(Task task) After instantiating a Task or a TaskGroup, use this method to run this Task. |
void |
startTaskOnThisThread(Task task) After instantiating a Task or a TaskGroup, use this method to run this Task. |
protected static void |
unsetTaskMonitor(java.lang.String key) UnSets the TaskMonitor object. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
protected static TaskID generateID()
public static TaskManager getInstance()
public TaskID startTask(Task task) throws TaskException
task
- The Task or TaskGroup to execute.TaskException
- in the event of an error in accepting or starting the task, an exception will be thrown. NOTE: If any exceptions are encountered during the execution of the task itself, such exception will be propagated via the task listeners.public java.util.concurrent.Future<?> enqueueTask(Task task)
public void startTaskOnThisThread(Task task) throws TaskException
task
- The Task or TaskGroup to execute.TaskException
- in the event of an error in accepting or starting the task, an exception will be thrown. NOTE: If any exceptions are encountered during the execution of the task itself, such exception will be propagated via the task listeners.public TaskID scheduleTask(Task task, TaskLockRequest lock) throws TaskException
task
- The task to be executed.lock
- the locks that is requested.TaskException
- if an error is encountered in accepting or scheduling the task. NOTE: if an error is encountered during the execution of the task itself, such exceptions are propagated via the Task Listener.public static TaskMonitor getTaskMonitor(java.lang.String key)
protected static void setTaskMonitor(java.lang.String key, TaskMonitor value)
protected static void unsetTaskMonitor(java.lang.String key)
|
Oracle Fusion Middleware Java API Reference for Oracle Extension SDK 11g Release 2 (11.1.2.2.0) E17493-03 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |