Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

oracle.ide.task
Class TaskManager

java.lang.Object
  extended by oracle.ide.task.TaskManager

public class TaskManager
extends java.lang.Object

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

generateID

protected static TaskID generateID()
Internal method

Returns:

getInstance

public static TaskManager getInstance()
Retrieves the singleton instance of the TaskManager

Returns:
TaskManager the instanceof TaskManager

startTask

public TaskID startTask(Task task)
                 throws TaskException
After instantiating a Task or a TaskGroup, use this method to run this Task. If feedback from this task or taskgroup is required, add the appropriate listener to the task or task group before starting. This method attempts to execute the task immidately, and assumes no resource locking contention will be encountered. For tasks that require resource locking (Workspace, Project or Node), use the scheduleTask() method.

Parameters:
task - The Task or TaskGroup to execute.
Returns:
the unique TaskID generated for this task.
Throws:
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.

enqueueTask

public java.util.concurrent.Future<?> enqueueTask(Task task)

startTaskOnThisThread

public void startTaskOnThisThread(Task task)
                           throws TaskException
After instantiating a Task or a TaskGroup, use this method to run this Task. If feedback from this task or taskgroup is required, add the appropriate listener to the task or task group before starting. This method attempts to execute the task immidately, and assumes no resource locking contention will be encountered. For tasks that require resource locking (Workspace, Project or Node), use the scheduleTask() method.

Parameters:
task - The Task or TaskGroup to execute.
Throws:
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.

scheduleTask

public TaskID scheduleTask(Task task,
                           TaskLockRequest lock)
                    throws TaskException
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. See details on TaskLockRequest to understand how the lock requests are structured. If certain tasks must be run in a particular order, they must be created as a TaskGroup and then scheduled. Scheduled tasks may be delayed depending on what other tasks have been started or scheduled already.

Parameters:
task - The task to be executed.
lock - the locks that is requested.
Returns:
the unique TaskID generated for this task.
Throws:
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.

getTaskMonitor

public static TaskMonitor getTaskMonitor(java.lang.String key)
Sets the TaskMonitor object. Protected methods.


setTaskMonitor

protected static void setTaskMonitor(java.lang.String key,
                                     TaskMonitor value)
Sets the TaskMonitor object. Protected methods.


unsetTaskMonitor

protected static void unsetTaskMonitor(java.lang.String key)
UnSets the TaskMonitor object. Protected methods.


Oracle Fusion Middleware Java API Reference for Oracle Extension SDK
11g Release 2 (11.1.2.0.0)

E17493-01

Copyright © 1997, 2011, Oracle. All rights reserved.