org.h2.util
Class TempFileDeleter

java.lang.Object
  extended by org.h2.util.TempFileDeleter

public class TempFileDeleter
extends java.lang.Object

This class deletes temporary files when they are not used any longer.


Method Summary
 java.lang.ref.Reference<?> addFile(java.lang.String fileName, java.lang.Object file)
          Add a file to the list of temp files to delete.
 void deleteAll()
          Delete all registered temp files.
 void deleteFile(java.lang.ref.Reference<?> ref, java.lang.String fileName)
          Delete the given file now.
 void deleteUnused()
          Delete all unused files now.
static TempFileDeleter getInstance()
           
 void stopAutoDelete(java.lang.ref.Reference<?> ref, java.lang.String fileName)
          This method is called if a file should no longer be deleted if the object is garbage collected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static TempFileDeleter getInstance()

addFile

public java.lang.ref.Reference<?> addFile(java.lang.String fileName,
                                          java.lang.Object file)
Add a file to the list of temp files to delete. The file is deleted once the file object is garbage collected.

Parameters:
fileName - the file name
file - the object to monitor
Returns:
the reference that can be used to stop deleting the file

deleteFile

public void deleteFile(java.lang.ref.Reference<?> ref,
                       java.lang.String fileName)
Delete the given file now. This will remove the reference from the list.

Parameters:
ref - the reference as returned by addFile
fileName - the file name

deleteAll

public void deleteAll()
Delete all registered temp files.


deleteUnused

public void deleteUnused()
Delete all unused files now.


stopAutoDelete

public void stopAutoDelete(java.lang.ref.Reference<?> ref,
                           java.lang.String fileName)
This method is called if a file should no longer be deleted if the object is garbage collected.

Parameters:
ref - the reference as returned by addFile
fileName - the file name