JAL-3878 Rename web service worker to more generic pollable task.
[jalview.git] / src / jalview / ws2 / WebServiceWorkerI.java
1 package jalview.ws2;
2
3 import java.io.IOException;
4 import java.util.List;
5
6 public interface WebServiceWorkerI extends PollableTaskI
7 {
8   long getUID();
9
10   List<WSJob> getJobs();
11
12   void start() throws IOException;
13
14   boolean poll() throws IOException;
15
16   WebServiceI getWebService();
17
18   default boolean isDone()
19   {
20     if (getJobs().size() == 0)
21       return false;
22     for (WSJob job : getJobs())
23     {
24       if (!job.getStatus().isDone() && !job.getStatus().isFailed())
25         return false;
26     }
27     return true;
28   }
29
30   /*
31    * Called by the executor when the worker transitions to the done state
32    * either normally or exceptionally.
33    */
34   void done();
35 }