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