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

E17493-01

oracle.ide.task
Class Task<T>

java.lang.Object
  extended by oracle.ide.task.Task<T>
Direct Known Subclasses:
CancellableTask, TaskGroup

public abstract class Task<T>
extends java.lang.Object

A Task encapsulates the threading artifacts to provide a standardized interface for performing operations on a user thread. The TaskManager provides access to the Task during execution and also fires events on behalf of the task to indicate changes in State of the task. The client must implement the performTask() method where the lengthy task is executed. The return result is of genericised, and is up to the implementor to choose.


Field Summary
protected  TaskState state
           
protected  TaskID taskID
           
 
Constructor Summary
Task(java.lang.String implementorID, int maxProgress)
          The constructor for a Task.
Task(java.lang.String implementorID, java.lang.String userTaskID, int maxProgress)
          The constructor for a Task.
 
Method Summary
 void addTaskListener(TaskListener tl)
          Add a TaskListener to the this task.
 TaskID getID()
          Retrieves the unique ID of the Task
 java.util.ArrayList<TaskListener> getListenerList()
          Retrieve the listener list for this task
 TaskEvent getNewTaskEvent()
          Get a new instance of TaskEvent.
abstract  T getResult()
          If the task has produced aretrieveable result, this method will allow retrieval.
 java.lang.String getShortName()
          Retrieves the implementor ID (not guranteed to be unique) It is expected to be meaningful to the implementor only.
 TaskState getState()
          Retrieve the current state of the Task.
abstract  int getTimeLeftSeconds()
          An estimate in seconds of the time left.
 int getTotalCount()
          A task implementor must provide a quantitative measure of the Task.
abstract  TaskExitCode performTask(TaskMonitor tc)
          This is the client method that will perform the actual work of this task.
 void removeTaskListener(TaskListener tl)
          Remove a TaskListener from the this task.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

taskID

protected TaskID taskID

state

protected TaskState state
Constructor Detail

Task

public Task(java.lang.String implementorID,
            int maxProgress)
The constructor for a Task. The implementor ID can be anything and is not used by the Task Management API. Usually it is the name with which the client wants the Task to be identified in visible lists of feedback UIs etc.

Parameters:
implementorID - the client-chosen ID, no requirements from the Task API.
maxProgress - int count of the maximum progress 'count' for this task. This is used for normalizing and firing taskUpdates for the sub-tasks of this task. Must be equal or greater than 100.

Task

public Task(java.lang.String implementorID,
            java.lang.String userTaskID,
            int maxProgress)
     throws TaskException
The constructor for a Task. The implementor ID can be anything and is not used by the Task Management API. Usually it is the name with which the client wants the Task to be identified in visible lists of feedback UIs etc.

Parameters:
implementorID - the client-chosen ID, no requirements from the Task API.
userTaskID - the client-chosen ID, must be unique. Uniqueness to be assured by the user.
maxProgress - int count of the maximum progress 'count' for this task. This is used for normalizing and firing taskUpdates for the sub-tasks of this task. Must be equal or greater than 100.
Throws:
TaskException
Method Detail

getListenerList

public java.util.ArrayList<TaskListener> getListenerList()
Retrieve the listener list for this task

Returns:
ArrayList

addTaskListener

public final void addTaskListener(TaskListener tl)
Add a TaskListener to the this task. The methods in the TaskListener are fired to indicate chagnes in the task state

Parameters:
tl - TaskListener which will be added to this task

removeTaskListener

public final void removeTaskListener(TaskListener tl)
Remove a TaskListener from the this task. The methods in the TaskListener are fired to indicate chagnes in the task state

Parameters:
tl - TaskListener that will be removed from this task

getID

public TaskID getID()
Retrieves the unique ID of the Task

Returns:
TaskID the TaskID generated by the TaskManager and used for identifying this task within the Task API.

getShortName

public java.lang.String getShortName()
Retrieves the implementor ID (not guranteed to be unique) It is expected to be meaningful to the implementor only.

Returns:
String the implementor ID which was supplied during the construction of the Task

getTotalCount

public int getTotalCount()
A task implementor must provide a quantitative measure of the Task. This must be consistent with the task progress updates. The maximum progress must not exceed this number. This is provided via the constructor of the Task, viz., the maxProgress parameter. The count values for tasks that belong to a group should reflect the variation of time taken for each task. They should not all have the same value (unless that is the actually the case).

Returns:
int declaration of the length of the task in counts.

getTimeLeftSeconds

public abstract int getTimeLeftSeconds()
An estimate in seconds of the time left.

Returns:
int the number of seconds that are left for this task.

getNewTaskEvent

public TaskEvent getNewTaskEvent()
Get a new instance of TaskEvent. This is to prevent the creation of the TaskEvent outside the package.

Returns:
TaskEvent an instance of a new TaskEvent

getState

public TaskState getState()
Retrieve the current state of the Task. The task state changes are enumerated as TaskState and only the TaskManager changes the state of any task in response to the performAction method or thread execution states.

Returns:
TaskState the state of the Task, an enumerated value

getResult

public abstract T getResult()
If the task has produced aretrieveable result, this method will allow retrieval.

Returns:
T the result from the Task if any. The type is specified during the construction of the Task. The result can be null. It is up to the implementor to decide.

performTask

public abstract TaskExitCode performTask(TaskMonitor tc)
                                  throws java.lang.Exception
This is the client method that will perform the actual work of this task.

Parameters:
tc - TaskMonitor this is the access point for the Task itself to access the services which are offered, for example providing progress update or acquaring locks etc.
Returns:
TaskExitCode the return value from the Task, an enumeration, indicating how the task ended. It is up to the implementor to return the correct value. The task manager will fire events based on this return value
Throws:
java.lang.Exception

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.