Package org.apache.commons.fileupload2.jakarta.servlet6

# Class JakartaFileCleaner

java.lang.Object
org.apache.commons.fileupload2.jakarta.servlet6.JakartaFileCleaner

All Implemented Interfaces:
  `ServletContextListener`, `EventListener`

public class JakartaFileCleaner extends Object implements ServletContextListener
A servlet context listener, which ensures that the `FileCleaningTracker`'s reaper thread is terminated, when the web application is destroyed.

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `static final String`
  `FILE_CLEANING_TRACKER_ATTRIBUTE`
  Attribute name, which is used for storing an instance of `FileCleaningTracker` in the web application.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `JakartaFileCleaner()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `contextDestroyed(ServletContextEvent sce)`
  Called when the web application is being destroyed.
  `void`
  `contextInitialized(ServletContextEvent sce)`
  Called when the web application is initialized.
  `static org.apache.commons.io.FileCleaningTracker`
  `getFileCleaningTracker(ServletContext servletContext)`
  Gets the instance of `FileCleaningTracker`, which is associated with the given `ServletContext`.
  `static void`
  `setFileCleaningTracker(ServletContext servletContext, org.apache.commons.io.FileCleaningTracker tracker)`
  Sets the instance of `FileCleaningTracker`, which is associated with the given `ServletContext`.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### FILE_CLEANING_TRACKER_ATTRIBUTE

    public static final String FILE_CLEANING_TRACKER_ATTRIBUTE
    Attribute name, which is used for storing an instance of `FileCleaningTracker` in the web application.

- ## Constructor Details

  - ### JakartaFileCleaner

    public JakartaFileCleaner()

- ## Method Details

  - ### getFileCleaningTracker

    public static org.apache.commons.io.FileCleaningTracker getFileCleaningTracker(ServletContext servletContext)
    Gets the instance of `FileCleaningTracker`, which is associated with the given `ServletContext`.
    Parameters:
      `servletContext` - The servlet context to query
    Returns:
      The contexts tracker

  - ### setFileCleaningTracker

    public static void setFileCleaningTracker(ServletContext servletContext, org.apache.commons.io.FileCleaningTracker tracker)
    Sets the instance of `FileCleaningTracker`, which is associated with the given `ServletContext`.
    Parameters:
      `servletContext` - The servlet context to modify
      `tracker` - The tracker to set

  - ### contextDestroyed

    public void contextDestroyed(ServletContextEvent sce)
    Called when the web application is being destroyed. Calls `FileCleaningTracker.exitWhenFinished()`.
    Specified by:
      `contextDestroyed` in interface `ServletContextListener`
    Parameters:
      `sce` - The servlet context, used for calling `getFileCleaningTracker(ServletContext)`.

  - ### contextInitialized

    public void contextInitialized(ServletContextEvent sce)
    Called when the web application is initialized. Does nothing.
    Specified by:
      `contextInitialized` in interface `ServletContextListener`
    Parameters:
      `sce` - The servlet context, used for calling `setFileCleaningTracker(ServletContext, FileCleaningTracker)`.