Top Description Fields Constructors Methods
org.h2.util

public Class TempFileDeleter

extends Object
Class Inheritance
Imports
java.lang.ref.PhantomReference, .Reference, .ReferenceQueue, java.util.ArrayList, .HashMap, org.h2.engine.SysProperties, org.h2.message.DbException, org.h2.store.fs.FileUtils

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

Field Summary

Modifier and TypeField and Description
private final ReferenceQueue<Object>
private final HashMap<PhantomReference<?>, Object>

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public synchronized Reference<?>

Returns:

the reference that can be used to stop deleting the file or closing the closeable
addFile
(Object
the file name or the closeable
resource
,
Object
the object to monitor
monitor
)

Add a file or a closeable to the list of temporary objects to delete.

public void
deleteAll()

Delete all registered temp resources.

public synchronized void
deleteFile(Reference<?>
the reference as returned by addFile
ref
,
Object
the file name or closeable
resource
)

Delete the given file or close the closeable now.

public void
deleteUnused()

Delete all unused resources now.

public static TempFileDeleter
public void
stopAutoDelete(Reference<?>
the reference as returned by addFile
ref
,
Object
file name or closeable
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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

queueback to summary
private final ReferenceQueue<Object> queue
refMapback to summary
private final HashMap<PhantomReference<?>, Object> refMap

Constructor Detail

TempFileDeleterback to summary
private TempFileDeleter()

Method Detail

addFileback to summary
public synchronized Reference<?> addFile(Object resource, 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:Object

the file name or the closeable

monitor:Object

the object to monitor

Returns:Reference<?>

the reference that can be used to stop deleting the file or closing the closeable

deleteAllback to summary
public void deleteAll()

Delete all registered temp resources.

deleteFileback to summary
public synchronized void deleteFile(Reference<?> ref, Object resource)

Delete the given file or close the closeable now. This will remove the reference from the list.

Parameters
ref:Reference<?>

the reference as returned by addFile

resource:Object

the file name or closeable

deleteUnusedback to summary
public void deleteUnused()

Delete all unused resources now.

getInstanceback to summary
public static TempFileDeleter getInstance()
stopAutoDeleteback to summary
public 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.

Parameters
ref:Reference<?>

the reference as returned by addFile

resource:Object

file name or closeable