Package org.h2.util
Class TempFileDeleter
- java.lang.Object
-
- org.h2.util.TempFileDeleter
-
public class TempFileDeleter extends java.lang.Object
This class deletes temporary files when they are not used any longer.
-
-
Constructor Summary
Constructors Modifier Constructor Description private
TempFileDeleter()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.ref.Reference<?>
addFile(java.lang.Object resource, java.lang.Object monitor)
Add a file or a closeable to the list of temporary objects to delete.void
deleteAll()
Delete all registered temp resources.void
deleteFile(java.lang.ref.Reference<?> ref, java.lang.Object resource)
Delete the given file or close the closeable now.void
deleteUnused()
Delete all unused resources now.static TempFileDeleter
getInstance()
void
stopAutoDelete(java.lang.ref.Reference<?> ref, java.lang.Object resource)
This method is called if a file should no longer be deleted or a resource should no longer be closed if the object is garbage collected.
-
-
-
Method Detail
-
getInstance
public static TempFileDeleter getInstance()
-
addFile
public java.lang.ref.Reference<?> addFile(java.lang.Object resource, java.lang.Object monitor)
Add a file or a closeable to the list of temporary objects to delete. The file is deleted once the file object is garbage collected.- Parameters:
resource
- the file name or the closeablemonitor
- the object to monitor- Returns:
- the reference that can be used to stop deleting the file or closing the closeable
-
deleteFile
public void deleteFile(java.lang.ref.Reference<?> ref, java.lang.Object resource)
Delete the given file or close the closeable now. This will remove the reference from the list.- Parameters:
ref
- the reference as returned by addFileresource
- the file name or closeable
-
deleteAll
public void deleteAll()
Delete all registered temp resources.
-
deleteUnused
public void deleteUnused()
Delete all unused resources now.
-
stopAutoDelete
public void stopAutoDelete(java.lang.ref.Reference<?> ref, java.lang.Object resource)
This method is called if a file should no longer be deleted or a resource should no longer be closed if the object is garbage collected.- Parameters:
ref
- the reference as returned by addFileresource
- file name or closeable
-
-