KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > directwebremoting > servlet > EfficientShutdownServletContextListener


1 /*
2  * Copyright 2005 Joe Walker
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.directwebremoting.servlet;
17
18 import java.util.List JavaDoc;
19
20 import javax.servlet.ServletContextEvent JavaDoc;
21 import javax.servlet.ServletContextListener JavaDoc;
22
23 import org.directwebremoting.extend.ServerLoadMonitor;
24 import org.directwebremoting.impl.ContainerUtil;
25
26 /**
27  * A {@link ServletContextListener} that can be used to call
28  * {@link ServerLoadMonitor#shutdown()} when the servlet container is stopped
29  * @author Joe Walker [joe at getahead dot ltd dot uk]
30  */

31 public class EfficientShutdownServletContextListener implements ServletContextListener JavaDoc
32 {
33     /* (non-Javadoc)
34      * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent)
35      */

36     public void contextInitialized(ServletContextEvent JavaDoc ev)
37     {
38     }
39
40     /* (non-Javadoc)
41      * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent)
42      */

43     public void contextDestroyed(ServletContextEvent JavaDoc ev)
44     {
45         List JavaDoc containers = ContainerUtil.getAllPublishedContainers(ev.getServletContext());
46         ContainerUtil.shutdownServerLoadMonitorsInContainerList(containers, "EfficientShutdownServletContextListener");
47     }
48 }
49
Popular Tags