Coverage Report - org.apache.myfaces.webapp.MyFacesServlet
 
Classes in this File Line Coverage Branch Coverage Complexity
MyFacesServlet
0%
0/27
0%
0/14
1.857
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.myfaces.webapp;
 20  
 
 21  
 import org.apache.commons.logging.Log;
 22  
 import org.apache.commons.logging.LogFactory;
 23  
 import org.apache.myfaces.shared_impl.webapp.webxml.DelegatedFacesServlet;
 24  
 import org.apache.myfaces.util.ContainerUtils;
 25  
 
 26  
 import javax.faces.webapp.FacesServlet;
 27  
 import javax.servlet.*;
 28  
 import java.io.IOException;
 29  
 
 30  
 /**
 31  
  * Derived FacesServlet that can be used for debugging purpose
 32  
  * and to fix the Weblogic startup issue (FacesServlet is initialized before ServletContextListener).
 33  
  *
 34  
  * @author Manfred Geiler (latest modification by $Author: skitching $)
 35  
  * @version $Revision: 684465 $ $Date: 2008-08-10 06:38:21 -0500 (Sun, 10 Aug 2008) $
 36  
  */
 37  0
 public class MyFacesServlet implements Servlet, DelegatedFacesServlet
 38  
 {
 39  0
     private static final Log log = LogFactory.getLog(MyFacesServlet.class);
 40  
 
 41  0
     private final FacesServlet delegate = new FacesServlet();
 42  
     
 43  
     private FacesInitializer _facesInitializer;
 44  
     
 45  
     protected FacesInitializer getFacesInitializer()
 46  
     {
 47  0
         if (_facesInitializer == null)
 48  
         {
 49  0
             if (ContainerUtils.isJsp21()) 
 50  
             {
 51  0
                 _facesInitializer = new Jsp21FacesInitializer();
 52  
             } 
 53  
             else 
 54  
             {
 55  0
                 _facesInitializer = new Jsp20FacesInitializer();
 56  
             }
 57  
         }
 58  
         
 59  0
         return _facesInitializer;
 60  
     }
 61  
     
 62  
     public void setFacesInitializer(FacesInitializer facesInitializer)
 63  
     {
 64  0
         _facesInitializer = facesInitializer;
 65  0
     }
 66  
 
 67  
     public void destroy()
 68  
     {
 69  0
         delegate.destroy();
 70  0
     }
 71  
 
 72  
     public ServletConfig getServletConfig()
 73  
     {
 74  0
         return delegate.getServletConfig();
 75  
     }
 76  
 
 77  
     public String getServletInfo()
 78  
     {
 79  0
         return delegate.getServletInfo();
 80  
     }
 81  
 
 82  
     public void init(ServletConfig servletConfig)
 83  
         throws ServletException
 84  
     {
 85  
         //Check, if ServletContextListener already called
 86  0
         ServletContext servletContext = servletConfig.getServletContext();
 87  0
         Boolean b = (Boolean)servletContext.getAttribute(StartupServletContextListener.FACES_INIT_DONE);
 88  0
         if (b == null || b.booleanValue() == false)
 89  
         {
 90  0
             if(log.isWarnEnabled())
 91  0
                 log.warn("ServletContextListener not yet called");
 92  0
             getFacesInitializer().initFaces(servletConfig.getServletContext());
 93  
         }
 94  0
         delegate.init(servletConfig);
 95  0
         log.info("MyFacesServlet for context '" + servletConfig.getServletContext().getRealPath("/") + "' initialized.");
 96  0
     }
 97  
 
 98  
     public void service(ServletRequest request, ServletResponse response)
 99  
             throws IOException,
 100  
                    ServletException
 101  
     {
 102  0
         if (log.isTraceEnabled()) log.trace("MyFacesServlet service start");
 103  0
         delegate.service(request, response);
 104  0
         if (log.isTraceEnabled()) log.trace("MyFacesServlet service finished");
 105  0
     }
 106  
 
 107  
 }