JAL-3878 Code reformatting.
[jalview.git] / src / jalview / ws2 / WebServiceWorkerI.java
index 1c40eb8..be719c1 100644 (file)
@@ -9,65 +9,31 @@ import jalview.util.MathUtils;
 
 public interface WebServiceWorkerI
 {
-  public class WSJob
-  {
-    public final long uid = MathUtils.getUID();
-    
-    protected WSJobState state = WSJobState.UNKNOWN;
-
-    protected String jobID = "";
-
-    protected int jobNum = 0;
+  long getUID();
 
-    protected int allowedExceptions = 3;
-
-    public long getUID() {
-      return uid;
-    }
-    
-    public WSJobState getState()
-    {
-      return state;
-    }
+  List<WSJob> getJobs();
 
-    public void setState(WSJobState state)
-    {
-      this.state = state;
-    }
+  void startJobs() throws IOException;
 
-    public String getJobID()
-    {
-      return jobID;
-    }
+  boolean pollJobs() throws IOException;
 
-    public void setJobID(String jobID) {
-      this.jobID = jobID;
-    }
-    
-    public int getJobNum()
-    {
-      return jobNum;
-    }
+  WebServiceI getWebService();
 
-    public int getAllowedExceptions()
+  default boolean isDone()
+  {
+    if (getJobs().size() == 0)
+      return false;
+    for (WSJob job : getJobs())
     {
-      return allowedExceptions;
-    }
-    
-    public boolean deductAllowedExceptions() {
-      return allowedExceptions-- > 0;
-    }
-    
-    public void resetAllowedExceptions() {
-      allowedExceptions = 3;
+      if (!job.getStatus().isDone())
+        return false;
     }
+    return true;
   }
 
-  public long getUID();
-
-  public List<WSJob> getJobs();
-
-  public WSJobID startJob(WSJob job) throws IOException;
-
-  public boolean pollJob(WSJob job) throws IOException;
+  /*
+   * Called by the executor when the worker transitions to the done state
+   * either normally or exceptionally.
+   */
+  void done();
 }