All Packages Class Hierarchy This Package Previous Next Index
Class com.sun.wizards.tasks.TmpFileTask
java.lang.Object
|
+----com.sun.wizards.core.Task
|
+----com.sun.wizards.tasks.TmpFileTask
- public class TmpFileTask
- extends Task
- implements ResourceWriter
The TmpFileTask is able to write temporary files directly from the wizard
archive. The temporary files are removed when the sequence is completed.
You might use this task to install a set of files in case of this Sequence
failing.
For example, assume you have a set of files you want to write in
case of an install failure (when the reverse() method would be
called), and then clean them up at the end of the Sequence. Assume
the data "tmpDir" is already set in the WizardState and points to a
valid temporary file directory. In your builder, you might use:
Sequence installSequence = new Sequence();
TmpFileTask uninstallFilesTask = new TmpFileTask("uninstallFiles", "tmpDir", Sequence.REVERSE);
// add files we want written out in case of failure
uninstallFilesTask.addFile("../uninstallfiles/wipeout");
uninstallFilesTask.addFile("../uninstallfiles/cleandisk");
// make task part of the main sequence
installSequence.addTask(uninstallFilesTask));
// register the task with the ArchiveWriter so that our files will be written
// into the Wizard archive, to later be extracted and written in case of a task
// failure.
addResource("uninstallFiles", uninstallFilesTask);
-
FORWARD
- Flag indicating task should write its files during the
perform() method.
-
REVERSE
- Flag indicating task should write its files during the
reverse() method.
-
TmpFileTask(String, String, boolean)
- Create a TmpFileTask that reads from the specified resource
section in the archive.
-
addFile(String)
- Adds the specified file or directory to the resource.
-
addRuntimeResources(Vector)
- Add the runtime class requirements to the specified vector.
-
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.
-
perform()
- Perform this Task.
-
requiresCleanup()
- If the task requires cleanup when the sequence has completed,
this method should return true.
-
reverse()
- Reverse this Task.
-
writeResource(DataOutput)
- This method writes the registered files into the archive.
-
writeTmpFiles()
- Write the files that are embedded in the wizard archive.
FORWARD
public static final boolean FORWARD
- Flag indicating task should write its files during the
perform() method.
REVERSE
public static final boolean REVERSE
- Flag indicating task should write its files during the
reverse() method.
TmpFileTask
public TmpFileTask(String resourceName,
String directoryKey,
boolean direction)
- Create a TmpFileTask that reads from the specified resource
section in the archive.
- Parameters:
- resourceName - The name of the archive resource containing
files for this task.
- directoryKey - The key within the wizardState that identifies
where the temporory files should be written.
- direction - Should be FORWARD if this task is to write its
files during the perform method, or REVERSE if
this task is to write its files during the
reverse method. This task always removes the
files when the sequence is finished.
perform
public void perform()
- Perform this Task.
- Overrides:
- perform in class Task
reverse
public void reverse()
- Reverse this Task.
- Overrides:
- reverse in class Task
requiresCleanup
public boolean requiresCleanup()
- If the task requires cleanup when the sequence has completed,
this method should return true.
- 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
ignore
public 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
writeTmpFiles
public boolean writeTmpFiles()
- Write the files that are embedded in the wizard archive.
- Returns:
- true, when the write is completed.
addFile
public void addFile(String path)
- Adds the specified file or directory to the resource.
- Parameters:
- path - The file or directory to be added to the resource
writeResource
public void writeResource(DataOutput out)
- This method writes the registered files into the archive.
- Parameters:
- out - The stream with which to write the registered files
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