KickJava   Java API By Example, From Geeks To Geeks.

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


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.ServletContextAttributeEvent JavaDoc;
21 import javax.servlet.ServletContextAttributeListener JavaDoc;
22
23 import org.directwebremoting.extend.ServerLoadMonitor;
24 import org.directwebremoting.impl.ContainerUtil;
25
26 /**
27  * A {@link ServletContextAttributeListener} 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 EfficientShutdownServletContextAttributeListener implements ServletContextAttributeListener JavaDoc
32 {
33     /* (non-Javadoc)
34      * @see javax.servlet.ServletContextAttributeListener#attributeAdded(javax.servlet.ServletContextAttributeEvent)
35      */

36     public void attributeAdded(ServletContextAttributeEvent JavaDoc ev)
37     {
38     }
39
40     /* (non-Javadoc)
41      * @see javax.servlet.ServletContextAttributeListener#attributeRemoved(javax.servlet.ServletContextAttributeEvent)
42      */

43     public void attributeRemoved(ServletContextAttributeEvent JavaDoc ev)
44     {
45         if (ev.getName().equals(ContainerUtil.ATTRIBUTE_CONTAINER_LIST))
46         {
47             List JavaDoc containers = (List JavaDoc) ev.getValue();
48             ContainerUtil.shutdownServerLoadMonitorsInContainerList(containers, "EfficientShutdownServletContextAttributeListener");
49         }
50     }
51
52     /* (non-Javadoc)
53      * @see javax.servlet.ServletContextAttributeListener#attributeReplaced(javax.servlet.ServletContextAttributeEvent)
54      */

55     public void attributeReplaced(ServletContextAttributeEvent JavaDoc ev)
56     {
57     }
58 }
59
60
Popular Tags