JAL-3878 Separate server job handle from task's sub jobs.
[jalview.git] / src / jalview / ws2 / actions / api / TaskI.java
1 package jalview.ws2.actions.api;
2
3 import java.util.List;
4
5 import jalview.viewmodel.AlignmentViewport;
6 import jalview.ws2.api.JobStatus;
7 import jalview.ws2.api.WebServiceJobHandle;
8
9 /**
10  * {@code TaskI} objects represent running services. Tasks are created by
11  * concrete implementations of {@link ActionI} and provide a view of the state
12  * of the underlying job(s).
13  * 
14  * @author mmwarowny
15  *
16  * @param <T>
17  *          task result type
18  */
19 public interface TaskI<T>
20 {
21   /**
22    * Get the current status of the task. The resultant status should be a
23    * combination of individual sub-job statuses.
24    * 
25    * @return global status of
26    */
27   JobStatus getStatus();
28
29   /**
30    * Get the current list of sub-jobs of that task.
31    * 
32    * @return sub-jobs
33    */
34   List<? extends JobI> getSubJobs();
35
36   /**
37    * Get the last result of the task or {@code null} if not present. Note that
38    * the result is subject to change for restartable tasks.
39    * 
40    * @return last task result
41    */
42   T getResult();
43
44   /**
45    * Cancel the task, stop all sub-jobs running on a server and stop all threads
46    * managing this task.
47    */
48   void cancel();
49 }