org.springframework.extensions.surf.task
Class AbstractTask

java.lang.Object
  extended by org.springframework.extensions.surf.task.AbstractTask
All Implemented Interfaces:
Task
Direct Known Subclasses:
ImportTask

public abstract class AbstractTask
extends Object
implements Task

Abstract implementation of a task which may be useful to developers who wish to write custom tasks.

Author:
muzquiano

Field Summary
protected  String creator
           
protected  String description
           
protected  Date endTime
           
protected  List<String> history
           
protected  String id
           
protected  boolean isCancelled
           
protected  boolean isError
           
protected  boolean isFinished
           
protected  boolean isRunning
           
protected  boolean isSuccess
           
protected static org.apache.commons.logging.Log logger
           
protected  String name
           
protected  int progress
           
protected  int progressSize
           
protected  Date startTime
           
protected  String status
           
protected  Throwable throwable
           
 
Constructor Summary
AbstractTask(String name)
          Instantiates a new abstract task.
 
Method Summary
abstract  void cancel()
          Cancels the task
abstract  void execute()
          Executes the task
 String getCreator()
          Returns the creator of the task
 String getDescription()
          Returns the description of the task
 Date getEndTime()
          The end time of the task
 List<String> getHistory()
          Full history of all status updates to the task
 String getId()
          Returns the internal id of the task
 String getName()
          Returns the name of the task
 int getProgress()
          Returns how far the task has progressed down the progress bar.
 int getProgressSize()
          Returns the total size of the progress bar.
 Date getStartTime()
          The start time of the task
 String getStatus()
          Current status of the task
 Throwable getThrowable()
          If the task resulted in an error, retrieves the throwable obtained by the task worker thread.
 void increment()
          Increments the progress
 boolean isCancelled()
          Whether the task was cancelled
 boolean isError()
          Whether the task resulted in an error
 boolean isFinished()
          Whether the tasks completed
 boolean isRunning()
          Whether the task is still running
 boolean isSuccess()
          Whether the task completed successfully
 void setCreator(String creator)
          Sets the creator of the task
 void setDescription(String description)
          Sets a description for the task
 void setStatus(String status)
          Sets the status
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static org.apache.commons.logging.Log logger

isError

protected boolean isError

isSuccess

protected boolean isSuccess

isFinished

protected boolean isFinished

isRunning

protected boolean isRunning

isCancelled

protected boolean isCancelled

throwable

protected Throwable throwable

id

protected String id

name

protected String name

description

protected String description

status

protected String status

progress

protected int progress

progressSize

protected int progressSize

history

protected List<String> history

creator

protected String creator

startTime

protected Date startTime

endTime

protected Date endTime
Constructor Detail

AbstractTask

public AbstractTask(String name)
Instantiates a new abstract task.

Parameters:
name - the name
Method Detail

increment

public void increment()
Description copied from interface: Task
Increments the progress

Specified by:
increment in interface Task

getId

public String getId()
Description copied from interface: Task
Returns the internal id of the task

Specified by:
getId in interface Task
Returns:
id

getName

public String getName()
Description copied from interface: Task
Returns the name of the task

Specified by:
getName in interface Task
Returns:
name

setDescription

public void setDescription(String description)
Description copied from interface: Task
Sets a description for the task

Specified by:
setDescription in interface Task

getDescription

public String getDescription()
Description copied from interface: Task
Returns the description of the task

Specified by:
getDescription in interface Task
Returns:
description

setCreator

public void setCreator(String creator)
Description copied from interface: Task
Sets the creator of the task

Specified by:
setCreator in interface Task

getCreator

public String getCreator()
Description copied from interface: Task
Returns the creator of the task

Specified by:
getCreator in interface Task
Returns:
creator

execute

public abstract void execute()
                      throws Throwable
Description copied from interface: Task
Executes the task

Specified by:
execute in interface Task
Throws:
Throwable

cancel

public abstract void cancel()
Description copied from interface: Task
Cancels the task

Specified by:
cancel in interface Task

isError

public boolean isError()
Description copied from interface: Task
Whether the task resulted in an error

Specified by:
isError in interface Task
Returns:

isSuccess

public boolean isSuccess()
Description copied from interface: Task
Whether the task completed successfully

Specified by:
isSuccess in interface Task
Returns:

isFinished

public boolean isFinished()
Description copied from interface: Task
Whether the tasks completed

Specified by:
isFinished in interface Task
Returns:

isRunning

public boolean isRunning()
Description copied from interface: Task
Whether the task is still running

Specified by:
isRunning in interface Task
Returns:

isCancelled

public boolean isCancelled()
Description copied from interface: Task
Whether the task was cancelled

Specified by:
isCancelled in interface Task
Returns:

getStartTime

public Date getStartTime()
Description copied from interface: Task
The start time of the task

Specified by:
getStartTime in interface Task
Returns:

getEndTime

public Date getEndTime()
Description copied from interface: Task
The end time of the task

Specified by:
getEndTime in interface Task
Returns:

getThrowable

public Throwable getThrowable()
Description copied from interface: Task
If the task resulted in an error, retrieves the throwable obtained by the task worker thread.

Specified by:
getThrowable in interface Task
Returns:

getStatus

public String getStatus()
Description copied from interface: Task
Current status of the task

Specified by:
getStatus in interface Task
Returns:

setStatus

public void setStatus(String status)
Description copied from interface: Task
Sets the status

Specified by:
setStatus in interface Task

getProgress

public int getProgress()
Description copied from interface: Task
Returns how far the task has progressed down the progress bar.

Specified by:
getProgress in interface Task
Returns:
progress count

getProgressSize

public int getProgressSize()
Description copied from interface: Task
Returns the total size of the progress bar.

Specified by:
getProgressSize in interface Task
Returns:
progress bar total size

getHistory

public List<String> getHistory()
Description copied from interface: Task
Full history of all status updates to the task

Specified by:
getHistory in interface Task
Returns:


Copyright © 2009 SpringSource, Inc. All Rights Reserved.