Class TaskService

java.lang.Object
org.wicketstuff.progressbar.spring.TaskService
All Implemented Interfaces:
ITaskService

public class TaskService extends Object implements ITaskService

Should be registered as SESSION scoped bean to prevent memory leaks with unfinished tasks.

TODO automatic cleanup of tasks
Author:
Christopher Hlubek (hlubek)
  • Constructor Details

    • TaskService

      public TaskService(Executor executor)
  • Method Details

    • schedule

      public Long schedule(Task task)
      Description copied from interface: ITaskService
      Schedules the task, but doesn't start!
      Specified by:
      schedule in interface ITaskService
      Parameters:
      task - The task to schedule
      Returns:
      Generated ID of the task
    • start

      public void start(Long taskId)
      Description copied from interface: ITaskService
      Start the task with given taskId
      Specified by:
      start in interface ITaskService
    • cancel

      public void cancel(Long taskId)
      Description copied from interface: ITaskService
      Cancel the task with given taskId. The task itself is responsible for stopping, so this should be considered as some type of "soft interrupt".
      Specified by:
      cancel in interface ITaskService
    • scheduleAndStart

      public Long scheduleAndStart(Task task)
      Description copied from interface: ITaskService
      Schedule and start a task. Equal to:
       Long taskId = taskService.schedule(task);
       taskService.start(taskId);
       
      Specified by:
      scheduleAndStart in interface ITaskService
      Returns:
      taskId for this Task
    • finish

      public void finish(Long taskId)
      Description copied from interface: ITaskService
      Cleanup the task with the given taskId and remove it from the task service. Should always be called to free the task and prevent memory leaks! Since this not really safe to do from a web page AJAX callback, you should always register the TaskService as a SESSION bean.
      Specified by:
      finish in interface ITaskService
    • getProgression

      public org.wicketstuff.progressbar.Progression getProgression(Long taskId)
      Description copied from interface: ITaskService
      Get the current progression of a task.
      Specified by:
      getProgression in interface ITaskService
      Returns:
      the current progression of a task.
    • getMessages

      public List<Task.Message> getMessages(Long taskId)
      Specified by:
      getMessages in interface ITaskService