com.atlassian.jira.task
Interface TaskDescriptor<V extends Serializable>

Type Parameters:
V - the result type.
All Superinterfaces:
Serializable
All Known Implementing Classes:
MockTaskDescriptor

public interface TaskDescriptor<V extends Serializable>
extends Serializable

TaskDescriptor decribes the state of a long running task.

Since:
v3.13

Method Summary
 String getDescription()
          Return the description of the task passed when it was created.
 long getElapsedRunTime()
          This returns number of milliseconds the task has been running for.
 Date getFinishedTimestamp()
          Return the date when the task was finished.
 String getProgressURL()
          Returns the URL that displays progress on this task.
 V getResult()
          This returns the result of the long running task.
 Date getStartedTimestamp()
          Return the date when the task was started.
 Date getSubmittedTimestamp()
          Return the date when the task was submitted.
 TaskContext getTaskContext()
          Return he context of task.
 Long getTaskId()
          Reuturn the identifier for this task.
 TaskProgressIndicator getTaskProgressIndicator()
          Return the TaskProgressIndicator associated with the task.
 String getUserName()
          Return the user that started to task.
 boolean isCancellable()
          Returns whether this supports requests to cancel it.
 boolean isCancelled()
          Returns whether cancellation of task has been requested.
 boolean isFinished()
          Tells if caller if the task has finished running or not.
 boolean isStarted()
          True if the task has been started.
 void setCancelled(boolean cancelled)
          Set flag to indicate this task has been cancelled;
 void setResult(V result)
          Store the result in the descriptor.
 

Method Detail

getResult

V getResult()
This returns the result of the long running task. Returns null if the task is not finished.

Returns:
the result of the long running task or null if it has not return value.

isStarted

boolean isStarted()
True if the task has been started.

Returns:
true if the task has been started.

isFinished

boolean isFinished()
Tells if caller if the task has finished running or not.

Returns:
true if the task has finished running.

getTaskId

Long getTaskId()
Reuturn the identifier for this task. This is only unique in the current execution of the JVM.

Returns:
The unique id of the task

getStartedTimestamp

Date getStartedTimestamp()
Return the date when the task was started.

Returns:
the time that task was started. null will be returned if the task has not started executing.

getFinishedTimestamp

Date getFinishedTimestamp()
Return the date when the task was finished.

Returns:
the time that task finished executing. null will be returned if the task has not finished executing.

getSubmittedTimestamp

Date getSubmittedTimestamp()
Return the date when the task was submitted.

Returns:
the time that task was submited to the TaskManager. A null value will never be returned as the task will always have a submission time.

getElapsedRunTime

long getElapsedRunTime()
This returns number of milliseconds the task has been running for. Will return zero if the task has not started. When the task has started but not finished, it will return the the difference between the current time and the time was started (i.e. it will change). When the task has finished, it will return the difference between the start time and the end time (i.e. it will not change).

Returns:
the elapsed run time in milliseconds.

getUserName

String getUserName()
Return the user that started to task.

Returns:
the user that caused the task to be submitted. This may be null.

getDescription

String getDescription()
Return the description of the task passed when it was created.

Returns:
a meaningful description of the task

getTaskContext

TaskContext getTaskContext()
Return he context of task. Code that starts long running tasks can implement their own variants of this.

Returns:
the context of the task. This method will never return null as a task must always have a context.

getProgressURL

String getProgressURL()
Returns the URL that displays progress on this task. It is built using the TaskContext.

Returns:
the URL that displays progress for this task. null cannot be returned.

getTaskProgressIndicator

TaskProgressIndicator getTaskProgressIndicator()
Return the TaskProgressIndicator associated with the task. A task will only have an indictator if its callable implements the ProvidesTaskProgress interface.

Returns:
the TaskProgressIndicator associated with the task or null if there isn't one.

isCancellable

boolean isCancellable()
Returns whether this supports requests to cancel it.

Returns:
true if cancellation is supported, and false otherwise
Since:
v5.2

isCancelled

boolean isCancelled()
Returns whether cancellation of task has been requested. Long-running operations should poll to see if task has been requested.

Returns:
true if cancellation has been requested, and false otherwise
Since:
v5.2

setCancelled

void setCancelled(boolean cancelled)
Set flag to indicate this task has been cancelled;

Parameters:
cancelled - Cancelled flag

setResult

void setResult(V result)
Store the result in the descriptor.

Parameters:
result - The Result


Copyright © 2002-2014 Atlassian. All Rights Reserved.