UML
API interface
package
EventType
1 public interface EventType { 2 String TASK_FINISHED = "task_finished"; 3 }
Executor
. 1 public interface the Executor { 2 / ** . 3 * submit tasks to be executed . 4 * @param Task task . 5 * @return asynchronously result acquisition target . 6 * / . 7 ResultFetcher Submit (the Task Task); . 8 }
ResultFetcher
. 1 public interface ResultFetcher { 2 / ** . 3 * get task ID . 4 * @return task ID . 5 * / . 6 String gettaskid (); . 7 . 8 / ** . 9 * synchronization results for crawling 10 * @return task results 11 * / 12 is TaskResult FETCH (); 13 is 14 / ** 15 * results asynchronous task monitor 16 * @param listener . 17 * / 18 is void FETCH (TaskEventListener listener); . 19 20 / ** 21 * to cancel the task 22 is * @return { @code to true} if successfully canceled, { @code to false otherwise} 23 is * / 24 Boolean Cancel (); 25 }
Task
. 1 public interface the Task <T> { 2 / ** . 3 * task execution . 4 * @param the params parameters to perform the required tasks . 5 * @return task execution result . 6 * / . 7 T Execute (Object the params); . 8 . 9 / ** 10 * get task ID . 11 * @return job ID 12 is * / 13 is String gettaskid (); 14 }
TaskEvent
. 1 public interface TaskEvent { 2 . 3 / ** . 4 * Get Event Type . 5 * @return event type . 6 * / . 7 String the getEventType (); . 8 }
Task Wait Listener
. 1 public interface TaskEventListener { 2 . 3 / ** . 4 * triggering event listener . 5 * @param Event Event . 6 * / . 7 void Trigger (TaskEvent Event); . 8 . 9 / ** 10 * Get Event Type . 11 * @return event type 12 * / 13 is String the getEventType (); 14 }
TaskResult
. 1 public interface TaskResult { 2 / ** . 3 * Data acquisition task result . 4 * @return task result objects . 5 * / . 6 Object the getData (); . 7 . 8 / ** . 9 * task state 10 * @return task state 11 * / 12 getTaskStatus String (); 13 is 14 / ** 15 * abnormality information 16 * @return task exception information . 17 * / 18 is String getExceptionMsg (); . 19 }
TaskStatus
1 public interface TaskStatus { 2 String SUBMITTED = "submitted"; 3 String RUNNING = "running"; 4 String SUCCEED = "succeed"; 5 String FAILED = "failed"; 6 String CANCELED = "canceled"; 7 }