X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws2%2FWebServiceWorkerI.java;h=da6e5400113cf560b68b901b0bbc6e6eea13eb6b;hb=4c565a64e0601ea344f1d587851d0aa48ff5c388;hp=1c40eb83149244667d6c3385e78bf80b34e16588;hpb=4ca53c1d66d18d6bda1466dd7d22359031aaaeed;p=jalview.git diff --git a/src/jalview/ws2/WebServiceWorkerI.java b/src/jalview/ws2/WebServiceWorkerI.java index 1c40eb8..da6e540 100644 --- a/src/jalview/ws2/WebServiceWorkerI.java +++ b/src/jalview/ws2/WebServiceWorkerI.java @@ -9,65 +9,29 @@ import jalview.util.MathUtils; public interface WebServiceWorkerI { - public class WSJob - { - public final long uid = MathUtils.getUID(); - - protected WSJobState state = WSJobState.UNKNOWN; + long getUID(); - protected String jobID = ""; + List getJobs(); - protected int jobNum = 0; + void startJobs() throws IOException; - protected int allowedExceptions = 3; + boolean pollJobs() throws IOException; - public long getUID() { - return uid; - } - - public WSJobState getState() - { - return state; - } - - public void setState(WSJobState state) - { - this.state = state; - } - - public String getJobID() - { - return jobID; - } - - public void setJobID(String jobID) { - this.jobID = jobID; - } - - public int getJobNum() - { - return jobNum; - } + WebServiceI getWebService(); - public int getAllowedExceptions() - { - return allowedExceptions; - } - - public boolean deductAllowedExceptions() { - return allowedExceptions-- > 0; - } - - public void resetAllowedExceptions() { - allowedExceptions = 3; + default boolean isDone() { + if (getJobs().size() == 0) + return false; + for (WSJob job : getJobs()) { + if (!job.getStatus().isDone()) + return false; } + return true; } - public long getUID(); - - public List 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(); }