All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class com.sun.wizards.tasks.DecoratorTask

java.lang.Object
   |
   +----com.sun.wizards.core.Task
           |
           +----com.sun.wizards.tasks.DecoratorTask

public abstract class DecoratorTask
extends Task
implements Serializable
The DecoratorTask is a task that follows the Decorator design pattern. This abstract task can be extended and used to perform a Task only if certain conditions are met. For example, suppose you wanted to perform actualTask only if balance is greater than 0. You could use the following class:


public class GreaterThanZeroDecoratorTask extends DecoratorTask { int balance; public boolean ignore(boolean direction) { if (balance > 0) return false; else return true; } }

Then, when instantiating the class, you would embed the task you conditionally wanted to perform by using the construction:

GreaterThanZeroTask sampleTask = new GreaterThanZeroTask(actualTask);
This method can be used to create arbitrary rules, as well as nesting DecoratorTasks within other DecoratorTasks (the equivelant of the boolean AND operator).


Variable Index

 o decoratedTask
The real task that the DecoratorTask is decorating.

Constructor Index

 o DecoratorTask()
Creates a DecoratorTask.
 o DecoratorTask(Task)
Creates a DecoratorTask task that will perform the specified task.

Method Index

 o addRuntimeResources(Vector)
Add the runtime class requirements to the specified vector.
 o cancel()
Cancel this task.
 o cleanup()
This method is called after the sequence has completed, and gives the task an opportunity to finish.
 o estimatedCompletionTime(boolean)
An estimation of how long it will take to complete this task, in milliseconds.
 o ignore(boolean)
Returns false if this task does not want to be ignored, or true if this task should be ignored.
 o initialize(Sequence)
Initialize this task.
 o perform()
Perform the decorated Task.
 o requiresCleanup()
If the task requires cleanup when the sequence has completed, this method should return true.
 o reverse()
Reverse the decorated Task.

Variables

 o decoratedTask
 protected Task decoratedTask
The real task that the DecoratorTask is decorating.

Constructors

 o DecoratorTask
 public DecoratorTask()
Creates a DecoratorTask.

 o DecoratorTask
 public DecoratorTask(Task decoratedTask)
Creates a DecoratorTask task that will perform the specified task.

Parameters:
decoratedTask - The task that is to be performed or reversed.

Methods

 o perform
 public void perform()
Perform the decorated Task.

Overrides:
perform in class Task
 o reverse
 public void reverse()
Reverse the decorated Task.

Overrides:
reverse in class Task
 o ignore
 public abstract boolean ignore(boolean direction)
Returns false if this task does not want to be ignored, or true if this task should be ignored.

Parameters:
direction - Which way we should traverse the product tree if we are ignoring the task
Returns:
true or false, depending on if this Task should be ignored.
Overrides:
ignore in class Task
 o estimatedCompletionTime
 public int estimatedCompletionTime(boolean direction)
An estimation of how long it will take to complete this task, in milliseconds.

Parameters:
direction - Which way we should traverse the product tree if we are ignoring the task
Returns:
The estimated time to complete in milliseconds.
Overrides:
estimatedCompletionTime in class Task
 o initialize
 public void initialize(Sequence sequence)
Initialize this task.

Parameters:
sequence - The sequence that manages this task.
Overrides:
initialize in class Task
 o cancel
 public void cancel()
Cancel this task.

Overrides:
cancel in class Task
 o requiresCleanup
 public boolean requiresCleanup()
If the task requires cleanup when the sequence has completed, this method should return true.

Returns:
true if this task requires cleamup after completion; false otherwise
Overrides:
requiresCleanup in class Task
 o cleanup
 public void cleanup()
This method is called after the sequence has completed, and gives the task an opportunity to finish. This method will only be called if requiresCleanup() returns true.

Overrides:
cleanup in class Task
 o addRuntimeResources
 public void addRuntimeResources(Vector resourceVector)
Add the runtime class requirements to the specified vector.

Parameters:
resourceVector - The vector containing all runtime resources for this wizard.
Overrides:
addRuntimeResources in class Task

All Packages  Class Hierarchy  This Package  Previous  Next  Index