Package org.h2.util
Class TempFileDeleter
java.lang.Object
org.h2.util.TempFileDeleter
This class deletes temporary files when they are not used any longer.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ReferenceQueue
<Object> private final HashMap
<PhantomReference<?>, Object> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReference
<?> Add a file or a closeable to the list of temporary objects to delete.void
Delete all registered temp resources.void
deleteFile
(Reference<?> ref, Object resource) Delete the given file or close the closeable now.void
Delete all unused resources now.static TempFileDeleter
void
stopAutoDelete
(Reference<?> ref, 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.
-
Field Details
-
queue
-
refMap
-
-
Constructor Details
-
TempFileDeleter
private TempFileDeleter()
-
-
Method Details
-
getInstance
-
addFile
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
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
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
-