Coverage Report - org.seasar.teeda.core.context.creator.DispatchableFacesContextCreator
 
Classes in this File Line Coverage Branch Coverage Complexity
DispatchableFacesContextCreator
100%
14/14
100%
4/4
1.8
 
 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.context.creator;
 17  
 
 18  
 import javax.faces.context.FacesContext;
 19  
 import javax.faces.lifecycle.Lifecycle;
 20  
 
 21  
 import org.seasar.teeda.core.context.creator.portlet.PortletEnvironmentUtil;
 22  
 import org.seasar.teeda.core.context.creator.portlet.PortletFacesContextCreator;
 23  
 import org.seasar.teeda.core.context.creator.servlet.ServletEnvironmentUtil;
 24  
 import org.seasar.teeda.core.context.creator.servlet.ServletFacesContextCreator;
 25  
 
 26  
 /**
 27  
  * @author shot
 28  
  * 
 29  
  */
 30  4
 public class DispatchableFacesContextCreator implements FacesContextCreator {
 31  
 
 32  4
     private ServletFacesContextCreator servletFacesContextCreator = new ServletFacesContextCreator();
 33  
 
 34  4
     private PortletFacesContextCreator portletFacesContextCreator = new PortletFacesContextCreator();
 35  
 
 36  
     //TODO need to change pluggable.
 37  
     public FacesContext create(Object context, Object request, Object response,
 38  
             Lifecycle lifecycle) {
 39  6
         if (ServletEnvironmentUtil.isServletEnvironment(context, request,
 40  
                 response)) {
 41  2
             return getServletFacesContextCreator().create(context, request,
 42  
                     response, lifecycle);
 43  4
         } else if (PortletEnvironmentUtil.isPortletEnvironment(context,
 44  
                 request, response)) {
 45  1
             return getPortletFacesContextCreator().create(context, request,
 46  
                     response, lifecycle);
 47  
         }
 48  3
         return null;
 49  
     }
 50  
 
 51  
     public PortletFacesContextCreator getPortletFacesContextCreator() {
 52  1
         return portletFacesContextCreator;
 53  
     }
 54  
 
 55  
     public void setPortletFacesContextCreator(
 56  
             PortletFacesContextCreator portletFacesContextCreator) {
 57  1
         this.portletFacesContextCreator = portletFacesContextCreator;
 58  1
     }
 59  
 
 60  
     public ServletFacesContextCreator getServletFacesContextCreator() {
 61  2
         return servletFacesContextCreator;
 62  
     }
 63  
 
 64  
     public void setServletFacesContextCreator(
 65  
             ServletFacesContextCreator servletFacesContextCreator) {
 66  1
         this.servletFacesContextCreator = servletFacesContextCreator;
 67  1
     }
 68  
 
 69  
 }