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).
-
decoratedTask
- The real task that the DecoratorTask is decorating.
-
DecoratorTask()
- Creates a DecoratorTask.
-
DecoratorTask(Task)
- Creates a DecoratorTask task that will perform the specified task.
-
addRuntimeResources(Vector)
-
Add the runtime class requirements to the specified vector.
-
cancel()
- Cancel this task.
-
cleanup()
- This method is called after the sequence has completed, and gives the
task an opportunity to finish.
-
estimatedCompletionTime(boolean)
- An estimation of how long it will take to complete
this task, in milliseconds.
-
ignore(boolean)
- Returns false if this task does not want to be
ignored, or true if this task should be ignored.
-
initialize(Sequence)
- Initialize this task.
-
perform()
- Perform the decorated Task.
-
requiresCleanup()
- If the task requires cleanup when the sequence has completed,
this method should return true.
-
reverse()
- Reverse the decorated Task.
decoratedTask
protected Task decoratedTask
- The real task that the DecoratorTask is decorating.
DecoratorTask
public DecoratorTask()
- Creates a DecoratorTask.
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.
perform
public void perform()
- Perform the decorated Task.
- Overrides:
- perform in class Task
reverse
public void reverse()
- Reverse the decorated Task.
- Overrides:
- reverse in class Task
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
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
initialize
public void initialize(Sequence sequence)
- Initialize this task.
- Parameters:
- sequence - The sequence that manages this task.
- Overrides:
- initialize in class Task
cancel
public void cancel()
- Cancel this task.
- Overrides:
- cancel in class Task
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
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
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