com.atlassian.confluence.util.longrunning
Class DefaultLongRunningTaskManager

java.lang.Object
  extended by com.atlassian.confluence.util.longrunning.DefaultLongRunningTaskManager
All Implemented Interfaces:
LongRunningTaskManager, org.springframework.beans.factory.DisposableBean

public class DefaultLongRunningTaskManager
extends Object
implements LongRunningTaskManager, org.springframework.beans.factory.DisposableBean


Constructor Summary
DefaultLongRunningTaskManager()
           
 
Method Summary
 void destroy()
           
 com.atlassian.core.task.longrunning.LongRunningTask getLongRunningTask(com.atlassian.user.User user, LongRunningTaskId id)
          gets a long running task with the given Id that was registered either by this user or the anonymous user.
 void resume()
          Resume accepting long-running tasks after LongRunningTaskManager.stop(long, java.util.concurrent.TimeUnit) has been called.
 LongRunningTaskId startLongRunningTask(com.atlassian.user.User user, com.atlassian.core.task.longrunning.LongRunningTask task)
          Start some task in a new thread
 void stop(long timeout, TimeUnit unit)
          Stop accepting new long running tasks.
 void stopTrackingLongRunningTask(LongRunningTaskId id)
          Clean up an old task.
protected  void taskFinished(LongRunningTaskId id)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultLongRunningTaskManager

public DefaultLongRunningTaskManager()
Method Detail

startLongRunningTask

public LongRunningTaskId startLongRunningTask(com.atlassian.user.User user,
                                              com.atlassian.core.task.longrunning.LongRunningTask task)
Description copied from interface: LongRunningTaskManager
Start some task in a new thread

Specified by:
startLongRunningTask in interface LongRunningTaskManager
Parameters:
user - the user responsible for the task
task - the task to perform
Returns:
an ID that can be used to look up the task

getLongRunningTask

public com.atlassian.core.task.longrunning.LongRunningTask getLongRunningTask(com.atlassian.user.User user,
                                                                              LongRunningTaskId id)
gets a long running task with the given Id that was registered either by this user or the anonymous user.

Specified by:
getLongRunningTask in interface LongRunningTaskManager
Parameters:
user - the user responsible for the task
id - the ID of the task
Returns:
the task, or null if no task is registered with that ID and user

stopTrackingLongRunningTask

public void stopTrackingLongRunningTask(LongRunningTaskId id)
Description copied from interface: LongRunningTaskManager
Clean up an old task. The manager hangs on to tasks that have been completed so their status can be queried. Calling this method will remove the task from the manager entirely.

This method does not stop a task from being executed. If the task is already running it will continue to completion, you just won't be able to query its status any more.

Specified by:
stopTrackingLongRunningTask in interface LongRunningTaskManager
Parameters:
id - the ID of the task to remove.

destroy

public void destroy()
             throws Exception
Specified by:
destroy in interface org.springframework.beans.factory.DisposableBean
Throws:
Exception

stop

public void stop(long timeout,
                 TimeUnit unit)
          throws TimeoutException
Description copied from interface: LongRunningTaskManager
Stop accepting new long running tasks. All tasks that have previously been submitted will be run to completion. If this takes longer than the timeout, the method will throw an exception and the task manager will resume normal operation accepting new tasks.

Specified by:
stop in interface LongRunningTaskManager
Parameters:
timeout - the time to wait for running tasks to complete
unit - the unit of measurement for the timeout parameter
Throws:
TimeoutException - if the timeout is exceeded

resume

public void resume()
Description copied from interface: LongRunningTaskManager
Resume accepting long-running tasks after LongRunningTaskManager.stop(long, java.util.concurrent.TimeUnit) has been called. If the long-running task manager is not stopped, this method will whistle quietly to itself and do nothing.

Specified by:
resume in interface LongRunningTaskManager

taskFinished

protected void taskFinished(LongRunningTaskId id)


Copyright © 2003-2013 Atlassian. All Rights Reserved.