Coverage Report - org.seasar.teeda.core.webapp.TeedaPortletExtendedConfigureListener
 
Classes in this File Line Coverage Branch Coverage Complexity
TeedaPortletExtendedConfigureListener
0%
0/26
0%
0/4
1.75
 
 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.PortletExtendedS2ContainerListener;
 23  
 import org.seasar.framework.log.Logger;
 24  
 import org.seasar.teeda.core.ProductInfo;
 25  
 
 26  
 /**
 27  
  * @author shot
 28  
  * @author manhole
 29  
  * @author shinsuke
 30  
  */
 31  0
 public class TeedaPortletExtendedConfigureListener extends
 32  
         PortletExtendedS2ContainerListener {
 33  
 
 34  0
     private static final String FACES_INIT_DONE = TeedaPortletExtendedConfigureListener.class
 35  
             .getName()
 36  
             + ".FACES_INIT_DONE";
 37  
 
 38  0
     private static Logger logger = Logger
 39  
             .getLogger(TeedaPortletExtendedConfigureListener.class);
 40  
 
 41  
     public void contextInitialized(ServletContextEvent event) {
 42  0
         super.contextInitialized(event);
 43  0
         printVersion();
 44  0
         logger.debug("JSF initialize start");
 45  
         try {
 46  0
             initializeFaces(event.getServletContext());
 47  0
         } catch (RuntimeException e) {
 48  0
             logger.log(e);
 49  0
             throw e;
 50  0
         }
 51  0
         logger.debug("JSF initialize end");
 52  0
     }
 53  
 
 54  
     public void contextDestroyed(ServletContextEvent event) {
 55  0
         super.contextDestroyed(event);
 56  0
         FactoryFinder.releaseFactories();
 57  0
     }
 58  
 
 59  
     protected void initializeFaces(ServletContext servletContext) {
 60  0
         Boolean b = (Boolean) servletContext.getAttribute(FACES_INIT_DONE);
 61  0
         boolean isAlreadyInitialized = (b != null) ? b.booleanValue() : false;
 62  0
         if (!isAlreadyInitialized) {
 63  0
             TeedaInitializer initializer = new TeedaInitializer();
 64  0
             initializer.setServletContext(servletContext);
 65  0
             initializer.initializeFaces();
 66  0
             servletContext.setAttribute(FACES_INIT_DONE, Boolean.TRUE);
 67  
         }
 68  
 
 69  0
     }
 70  
 
 71  
     private void printVersion() {
 72  0
         logger.debug("Teeda version :" + ProductInfo.getVersion());
 73  0
     }
 74  
 }