Coverage Report - org.seasar.teeda.core.webapp.TeedaConfigureListener
 
Classes in this File Line Coverage Branch Coverage Complexity
TeedaConfigureListener
0%
0/29
0%
0/4
2.25
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 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,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.teeda.core.webapp;
 17  
 
 18  
 import javax.faces.FactoryFinder;
 19  
 import javax.servlet.ServletContext;
 20  
 import javax.servlet.ServletContextEvent;
 21  
 
 22  
 import org.seasar.framework.container.servlet.S2ContainerListener;
 23  
 import org.seasar.framework.log.Logger;
 24  
 import org.seasar.teeda.core.ProductInfo;
 25  
 
 26  
 /**
 27  
  * @author shot
 28  
  * @author manhole
 29  
  */
 30  0
 public class TeedaConfigureListener extends S2ContainerListener {
 31  
 
 32  0
     private static final String FACES_INIT_DONE = TeedaConfigureListener.class
 33  
             .getName() +
 34  
             ".FACES_INIT_DONE";
 35  
 
 36  0
     private static Logger logger = Logger
 37  
             .getLogger(TeedaConfigureListener.class);
 38  
 
 39  
     public void contextInitialized(ServletContextEvent event) {
 40  0
         super.contextInitialized(event);
 41  0
         printVersion();
 42  0
         logger.debug("JSF initialize start");
 43  
         try {
 44  0
             initializeFaces(event.getServletContext());
 45  0
         } catch (RuntimeException e) {
 46  0
             logger.log(e);
 47  0
             throw e;
 48  0
         } catch (Error e) {
 49  0
             logger.log(e);
 50  0
             throw e;
 51  0
         }
 52  0
         logger.debug("JSF initialize end");
 53  0
     }
 54  
 
 55  
     public void contextDestroyed(ServletContextEvent event) {
 56  0
         super.contextDestroyed(event);
 57  0
         FactoryFinder.releaseFactories();
 58  0
     }
 59  
 
 60  
     protected void initializeFaces(ServletContext servletContext) {
 61  0
         Boolean b = (Boolean) servletContext.getAttribute(FACES_INIT_DONE);
 62  0
         boolean isAlreadyInitialized = (b != null) ? b.booleanValue() : false;
 63  0
         if (!isAlreadyInitialized) {
 64  0
             TeedaInitializer initializer = new TeedaInitializer();
 65  0
             initializer.setServletContext(servletContext);
 66  0
             initializer.initializeFaces();
 67  0
             servletContext.setAttribute(FACES_INIT_DONE, Boolean.TRUE);
 68  
         }
 69  
 
 70  0
     }
 71  
 
 72  
     private void printVersion() {
 73  0
         logger.debug("Teeda version :" + ProductInfo.getVersion());
 74  0
     }
 75  
 }