org.wicketstuff.progressbar.spring
Class TaskService

java.lang.Object
  extended by 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 Summary
TaskService(Executor executor)
           
 
Method Summary
 void cancel(Long taskId)
          Cancel the task with given taskId.
 void finish(Long taskId)
          Cleanup the task with the given taskId and remove it from the task service.
 List<Task.Message> getMessages(Long taskId)
           
 org.wicketstuff.progressbar.Progression getProgression(Long taskId)
          Get the current progression of a task.
 Long schedule(Task task)
          Schedules the task, but doesn't start!
 Long scheduleAndStart(Task task)
          Schedule and start a task.
 void start(Long taskId)
          Start the task with given taskId
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TaskService

public TaskService(Executor executor)
Method Detail

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


Copyright © 2007–2016. All rights reserved.