X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws2%2Factions%2Fapi%2FTaskEventListener.java;h=b0bb4b63fe5373078c1b2eab4e49113726b5a153;hb=4df015be529a2e1b12c6b82b061798e186cc154b;hp=f48272a1c350a5f0391bd0c15473d7cea1695daf;hpb=d19882378d8912834a5e196a30f78491cb1e621a;p=jalview.git diff --git a/src/jalview/ws2/actions/api/TaskEventListener.java b/src/jalview/ws2/actions/api/TaskEventListener.java index f48272a..b0bb4b6 100644 --- a/src/jalview/ws2/actions/api/TaskEventListener.java +++ b/src/jalview/ws2/actions/api/TaskEventListener.java @@ -2,6 +2,7 @@ package jalview.ws2.actions.api; import java.util.List; +import jalview.bin.Console; import jalview.ws2.api.JobStatus; import jalview.ws2.api.WebServiceJobHandle; @@ -29,7 +30,7 @@ public interface TaskEventListener * @param subJobs * list of sub-jobs for this run */ - void taskStarted(TaskI source, List subJobs); + default void taskStarted(TaskI source, List subJobs) {}; /** * Invoked when the global task status has changed. @@ -39,7 +40,7 @@ public interface TaskEventListener * @param status * new task status */ - void taskStatusChanged(TaskI source, JobStatus status); + default void taskStatusChanged(TaskI source, JobStatus status) {}; /** * Invoked when the task has completed. If the task completed with a result, @@ -51,7 +52,7 @@ public interface TaskEventListener * @param result * computation result or null if result not present */ - void taskCompleted(TaskI source, T result); + default void taskCompleted(TaskI source, T result) {}; /** * Invoked when an unhandled exception has occurred during task execution. @@ -61,8 +62,7 @@ public interface TaskEventListener * @param e * exception */ - void taskException(TaskI source, Exception e); - + default void taskException(TaskI source, Exception e) {}; /** * Invoked when the status of a sub-job has changed. @@ -74,7 +74,7 @@ public interface TaskEventListener * @param status * new job status */ - void subJobStatusChanged(TaskI source, JobI job, JobStatus status); + default void subJobStatusChanged(TaskI source, JobI job, JobStatus status) {}; /** * Invoked when a log string of the sub-job has changed. @@ -86,7 +86,7 @@ public interface TaskEventListener * @param log * new log string */ - void subJobLogChanged(TaskI source, JobI job, String log); + default void subJobLogChanged(TaskI source, JobI job, String log) {}; /** * Invoked when an error log string of the sub-job has changed. @@ -98,5 +98,56 @@ public interface TaskEventListener * @param log * new log string */ - void subJobErrorLogChanged(TaskI source, JobI job, String log); + default void subJobErrorLogChanged(TaskI source, JobI job, String log) {}; + + @SuppressWarnings("rawtypes") + static final TaskEventListener NULL_LISTENER = new TaskEventListener() + { + @Override + public void taskStarted(TaskI source, List subJobs) + { + Console.info("task started with " + subJobs.size() + " jobs"); + } + + @Override + public void taskStatusChanged(TaskI source, JobStatus status) + { + Console.info("task status " + status); + } + + @Override + public void taskCompleted(TaskI source, Object result) + { + Console.info("task completed"); + } + + @Override + public void taskException(TaskI source, Exception e) + { + Console.info("task failed", e); + } + + @Override + public void subJobStatusChanged(TaskI source, JobI job, + JobStatus status) + { + Console.info("sub-job " + job.getInternalId() + " status " + status); + } + + @Override + public void subJobLogChanged(TaskI source, JobI job, String log) + { + } + + @Override + public void subJobErrorLogChanged(TaskI source, JobI job, String log) + { + } + }; + + @SuppressWarnings("unchecked") + static TaskEventListener nullListener() + { + return (TaskEventListener) NULL_LISTENER; + } }