Class JakartaFileCleaner
- java.lang.Object
-
- org.apache.commons.fileupload2.jakarta.JakartaFileCleaner
-
- All Implemented Interfaces:
jakarta.servlet.ServletContextListener,EventListener
public class JakartaFileCleaner extends Object implements jakarta.servlet.ServletContextListener
A servlet context listener, which ensures that theFileCleaningTracker's reaper thread is terminated, when the web application is destroyed.
-
-
Field Summary
Fields Modifier and Type Field Description static StringFILE_CLEANING_TRACKER_ATTRIBUTEAttribute name, which is used for storing an instance ofFileCleaningTrackerin the web application.
-
Constructor Summary
Constructors Constructor Description JakartaFileCleaner()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcontextDestroyed(jakarta.servlet.ServletContextEvent sce)Called when the web application is being destroyed.voidcontextInitialized(jakarta.servlet.ServletContextEvent sce)Called when the web application is initialized.static org.apache.commons.io.FileCleaningTrackergetFileCleaningTracker(jakarta.servlet.ServletContext servletContext)Gets the instance ofFileCleaningTracker, which is associated with the givenServletContext.static voidsetFileCleaningTracker(jakarta.servlet.ServletContext servletContext, org.apache.commons.io.FileCleaningTracker tracker)Sets the instance ofFileCleaningTracker, which is associated with the givenServletContext.
-
-
-
Field Detail
-
FILE_CLEANING_TRACKER_ATTRIBUTE
public static final String FILE_CLEANING_TRACKER_ATTRIBUTE
Attribute name, which is used for storing an instance ofFileCleaningTrackerin the web application.
-
-
Constructor Detail
-
JakartaFileCleaner
public JakartaFileCleaner()
-
-
Method Detail
-
getFileCleaningTracker
public static org.apache.commons.io.FileCleaningTracker getFileCleaningTracker(jakarta.servlet.ServletContext servletContext)
Gets the instance ofFileCleaningTracker, which is associated with the givenServletContext.- Parameters:
servletContext- The servlet context to query- Returns:
- The contexts tracker
-
setFileCleaningTracker
public static void setFileCleaningTracker(jakarta.servlet.ServletContext servletContext, org.apache.commons.io.FileCleaningTracker tracker)
Sets the instance ofFileCleaningTracker, which is associated with the givenServletContext.- Parameters:
servletContext- The servlet context to modifytracker- The tracker to set
-
contextDestroyed
public void contextDestroyed(jakarta.servlet.ServletContextEvent sce)
Called when the web application is being destroyed. CallsFileCleaningTracker.exitWhenFinished().- Specified by:
contextDestroyedin interfacejakarta.servlet.ServletContextListener- Parameters:
sce- The servlet context, used for callinggetFileCleaningTracker(ServletContext).
-
contextInitialized
public void contextInitialized(jakarta.servlet.ServletContextEvent sce)
Called when the web application is initialized. Does nothing.- Specified by:
contextInitializedin interfacejakarta.servlet.ServletContextListener- Parameters:
sce- The servlet context, used for callingsetFileCleaningTracker(ServletContext, FileCleaningTracker).
-
-