01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.commons.fileupload.servlet;
18:
19: import javax.servlet.ServletContextListener;
20: import javax.servlet.ServletContextEvent;
21:
22: import org.apache.commons.io.FileCleaner;
23:
24: /**
25: * A servlet context listener, which ensures that the
26: * {@link org.apache.commons.io.FileCleaner FileCleaner's}
27: * reaper thread is terminated,
28: * when the web application is destroyed.
29: */
30: public class FileCleanerCleanup implements ServletContextListener {
31: /**
32: * Called when the web application is initialized. Does
33: * nothing.
34: * @param sce The servlet context (ignored).
35: */
36: public void contextInitialized(ServletContextEvent sce) {
37: // Does nothing.
38: }
39:
40: /**
41: * Called when the web application is being destroyed.
42: * Calls {@link FileCleaner#exitWhenFinished()}.
43: * @param sce The servlet context (ignored).
44: */
45: public void contextDestroyed(ServletContextEvent sce) {
46: FileCleaner.exitWhenFinished();
47: }
48: }
|