Coverage Report - org.apache.tiles.web.startup.AbstractTilesListener
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractTilesListener
100%
7/7
N/A
1
 
 1  
 /*
 2  
  * $Id: AbstractTilesListener.java 952763 2010-06-08 18:28:16Z apetrelli $
 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  
 package org.apache.tiles.web.startup;
 22  
 
 23  
 import javax.servlet.ServletContext;
 24  
 import javax.servlet.ServletContextEvent;
 25  
 import javax.servlet.ServletContextListener;
 26  
 
 27  
 import org.apache.tiles.request.servlet.ServletApplicationContext;
 28  
 import org.apache.tiles.startup.TilesInitializer;
 29  
 
 30  
 /**
 31  
  * Listener for the initialization of the Tiles container.
 32  
  *
 33  
  * @version $Rev: 952763 $ $Date: 2010-06-09 04:28:16 +1000 (Wed, 09 Jun 2010) $
 34  
  */
 35  1
 public abstract class AbstractTilesListener implements ServletContextListener {
 36  
 
 37  
     /**
 38  
      * The initializer object.
 39  
      *
 40  
      * @since 2.1.2
 41  
      */
 42  
     protected TilesInitializer initializer;
 43  
 
 44  
     /**
 45  
      * Initialize the TilesContainer and place it
 46  
      * into service.
 47  
      *
 48  
      * @param event The intercepted event.
 49  
      */
 50  
     public void contextInitialized(ServletContextEvent event) {
 51  1
         ServletContext servletContext = event.getServletContext();
 52  1
         initializer = createTilesInitializer();
 53  1
         initializer.initialize(new ServletApplicationContext(
 54  
                 servletContext));
 55  1
     }
 56  
 
 57  
     /**
 58  
      * Destroys the initializer.
 59  
      *
 60  
      * @param event The intercepted event.
 61  
      */
 62  
     public void contextDestroyed(ServletContextEvent event) {
 63  1
         initializer.destroy();
 64  1
     }
 65  
 
 66  
     /**
 67  
      * Creates a new instance of {@link TilesInitializer}. Implement it to use a
 68  
      * different initializer.
 69  
      *
 70  
      * @return The Tiles servlet-based initializer.
 71  
      * @since 2.2.0
 72  
      */
 73  
     protected abstract TilesInitializer createTilesInitializer();
 74  
 }