Apache Tomcat 7.0.42

org.apache.tomcat.util.http.fileupload
Class FileCleaningTracker

java.lang.Object
  extended by org.apache.tomcat.util.http.fileupload.FileCleaningTracker

public class FileCleaningTracker
extends Object

Keeps track of files awaiting deletion, and deletes them when an associated marker object is reclaimed by the garbage collector.

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.

Version:
$Id$

Constructor Summary
FileCleaningTracker()
           
 
Method Summary
 void track(File file, Object marker)
          Track the specified file, using the provided marker, deleting the file when the marker instance is garbage collected.
 void track(File file, Object marker, FileDeleteStrategy deleteStrategy)
          Track the specified file, using the provided marker, deleting the file when the marker instance is garbage collected.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileCleaningTracker

public FileCleaningTracker()
Method Detail

track

public void track(File file,
                  Object marker)
Track the specified file, using the provided marker, deleting the file when the marker instance is garbage collected. The normal deletion strategy will be used.

Parameters:
file - the file to be tracked, not null
marker - the marker object used to track the file, not null
Throws:
NullPointerException - if the file is null

track

public void track(File file,
                  Object marker,
                  FileDeleteStrategy deleteStrategy)
Track the specified file, using the provided marker, deleting the file when the marker instance is garbage collected. The speified deletion strategy is used.

Parameters:
file - the file to be tracked, not null
marker - the marker object used to track the file, not null
deleteStrategy - the strategy to delete the file, null means normal
Throws:
NullPointerException - if the file is null

Apache Tomcat 7.0.42

Copyright © 2000-2013 Apache Software Foundation. All Rights Reserved.