public class FileCleaningTracker
extends java.lang.Object
This utility creates a background thread to handle file deletion. Each file to be deleted is registered with a handler object. When the handler object is garbage collected, the file is deleted.
In an environment with multiple class loaders (a servlet container, for
example), you should consider stopping the background thread if it is no
longer needed. This is done by invoking the method
exitWhenFinished
, typically in
ServletContextListener.contextDestroyed(javax.servlet.ServletContextEvent)
or similar.
Constructor and Description |
---|
FileCleaningTracker() |
Modifier and Type | Method and Description |
---|---|
void |
track(java.io.File file,
java.lang.Object marker)
Track the specified file, using the provided marker, deleting the file
when the marker instance is garbage collected.
|
void |
track(java.io.File file,
java.lang.Object marker,
FileDeleteStrategy deleteStrategy)
Track the specified file, using the provided marker, deleting the file
when the marker instance is garbage collected.
|
public void track(java.io.File file, java.lang.Object marker)
normal
deletion strategy will be used.file
- the file to be tracked, not nullmarker
- the marker object used to track the file, not nulljava.lang.NullPointerException
- if the file is nullpublic void track(java.io.File file, java.lang.Object marker, FileDeleteStrategy deleteStrategy)
file
- the file to be tracked, not nullmarker
- the marker object used to track the file, not nulldeleteStrategy
- the strategy to delete the file, null means normaljava.lang.NullPointerException
- if the file is nullCopyright © 2000-2015 Apache Software Foundation. All Rights Reserved.