Class CleanupHook

java.lang.Object
noaa.coastwatch.tools.CleanupHook
All Implemented Interfaces:
Runnable

public class CleanupHook extends Object implements Runnable
The CleanupHook class may be used by programs to clean up resources after the Java VM has exited. The hook has only one instance, retrieved using the getInstance() method, and registers itself to be run using the Runtime.addShutdownHook(java.lang.Thread) method. Currently, the only cleanup task is file deletion.
Since:
3.1.9
Author:
Peter Hollemans
  • Method Details

    • getInstance

      public static CleanupHook getInstance()
      Gets the one and only instance of this class.
    • scheduleDelete

      public void scheduleDelete(String fileName)
      Adds a file to the set of files to delete upon cleanup. If the file was already scheduled for deletion, no action is performed.
      Parameters:
      fileName - the file name to add.
    • scheduleDelete

      public void scheduleDelete(File file)
      Adds a file to the set of files to delete upon cleanup. If the file was already scheduled for deletion, no action is performed.
      Parameters:
      file - the file to add.
    • cancelDelete

      public void cancelDelete(String fileName)
      Removes a file from the set of files to delete upon cleanup. If the file was never scheduled for deletion, no action is performed.
      Parameters:
      fileName - the file name to remove.
    • cancelDelete

      public void cancelDelete(File file)
      Removes a file from the set of files to delete upon cleanup. If the file was never scheduled for deletion, no action is performed.
      Parameters:
      file - the file to remove.
    • run

      public void run()
      Performs the cleanup. This method is normally only called in response to a system shutdown.
      Specified by:
      run in interface Runnable