org.apache.tomcat.util.http.fileupload

## Class FileCleaningTracker

- java.lang.Object
- - org.apache.tomcat.util.http.fileupload.FileCleaningTracker

-     public class FileCleaningTracker
      extends java.lang.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.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `FileCleaningTracker()`

  - ### Method Summary

    Methods
    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.

    - ### 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(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. 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:
        `java.lang.NullPointerException` - if the file is null

    - #### track

          public 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. 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:
        `java.lang.NullPointerException` - if the file is null

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