| %line | %branch | |||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| org.apache.jcs.utils.servlet.JCSServletContextListener |
|
|
| 1 | package org.apache.jcs.utils.servlet; |
|
| 2 | ||
| 3 | /* |
|
| 4 | * Licensed to the Apache Software Foundation (ASF) under one |
|
| 5 | * or more contributor license agreements. See the NOTICE file |
|
| 6 | * distributed with this work for additional information |
|
| 7 | * regarding copyright ownership. The ASF licenses this file |
|
| 8 | * to you under the Apache License, Version 2.0 (the |
|
| 9 | * "License"); you may not use this file except in compliance |
|
| 10 | * with the License. You may obtain a copy of the License at |
|
| 11 | * |
|
| 12 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
| 13 | * |
|
| 14 | * Unless required by applicable law or agreed to in writing, |
|
| 15 | * software distributed under the License is distributed on an |
|
| 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
|
| 17 | * KIND, either express or implied. See the License for the |
|
| 18 | * specific language governing permissions and limitations |
|
| 19 | * under the License. |
|
| 20 | */ |
|
| 21 | ||
| 22 | import javax.servlet.ServletContextEvent; |
|
| 23 | import javax.servlet.ServletContextListener; |
|
| 24 | ||
| 25 | import org.apache.commons.logging.Log; |
|
| 26 | import org.apache.commons.logging.LogFactory; |
|
| 27 | import org.apache.jcs.engine.control.CompositeCacheManager; |
|
| 28 | ||
| 29 | /** |
|
| 30 | * If you add this to the context listeners section of your web.xml file, this will shutdown JCS |
|
| 31 | * gracefully. |
|
| 32 | * <p> |
|
| 33 | * Add the following to the top of your web.xml file. |
|
| 34 | * |
|
| 35 | * <pre> |
|
| 36 | * <listener> |
|
| 37 | * <listener-class> |
|
| 38 | * org.apache.jcs.utils.servlet.JCSServletContextListener |
|
| 39 | * </listener-class> |
|
| 40 | * </listener> |
|
| 41 | * </pre> |
|
| 42 | * |
|
| 43 | * @author Aaron Smuts |
|
| 44 | */ |
|
| 45 | 0 | public class JCSServletContextListener |
| 46 | implements ServletContextListener |
|
| 47 | { |
|
| 48 | 0 | private static final Log log = LogFactory.getLog( JCSServletContextListener.class ); |
| 49 | ||
| 50 | /** |
|
| 51 | * This does nothing. We don't want to initialize the cache here. |
|
| 52 | * <p> |
|
| 53 | * (non-Javadoc) |
|
| 54 | * @see javax.servlet.ServletContextListener#contextInitialized(javax.servlet.ServletContextEvent) |
|
| 55 | */ |
|
| 56 | public void contextInitialized( ServletContextEvent arg0 ) |
|
| 57 | { |
|
| 58 | 0 | if ( log.isInfoEnabled() ) |
| 59 | { |
|
| 60 | 0 | log.info( "contextInitialized" ); |
| 61 | } |
|
| 62 | 0 | } |
| 63 | ||
| 64 | /** |
|
| 65 | * This gets the singleton instance of the CompositeCacheManager and calls shutdown. |
|
| 66 | * <p> |
|
| 67 | * (non-Javadoc) |
|
| 68 | * @see javax.servlet.ServletContextListener#contextDestroyed(javax.servlet.ServletContextEvent) |
|
| 69 | */ |
|
| 70 | public void contextDestroyed( ServletContextEvent arg0 ) |
|
| 71 | { |
|
| 72 | 0 | if ( log.isInfoEnabled() ) |
| 73 | { |
|
| 74 | 0 | log.info( "contextDestroyed, shutting down JCS." ); |
| 75 | } |
|
| 76 | 0 | CompositeCacheManager.getInstance().shutDown(); |
| 77 | 0 | } |
| 78 | ||
| 79 | } |
| This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |