Coverage Report - org.seasar.teeda.core.util.PortletUtil
 
Classes in this File Line Coverage Branch Coverage Complexity
PortletUtil
62%
5/8
75%
3/4
2.333
 
 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.util;
 17  
 
 18  
 import javax.faces.context.FacesContext;
 19  
 import javax.portlet.RenderResponse;
 20  
 
 21  
 import org.seasar.teeda.core.context.portlet.PortletFacesContextImpl;
 22  
 
 23  
 /**
 24  
  * This is a utility class to check if a process is on Portlet environment.
 25  
  * 
 26  
  * @author shinsuke
 27  
  * 
 28  
  */
 29  
 public class PortletUtil {
 30  
 
 31  
     /** do not allow a new instance */
 32  0
     private PortletUtil() {
 33  0
     }
 34  
 
 35  
     /**
 36  
      *  Check if the thread is running on Portlet.
 37  
      * 
 38  
      * @param facesContext
 39  
      * @return
 40  
      */
 41  
     public static boolean isPortlet(FacesContext facesContext) {
 42  51
         if (facesContext instanceof PortletFacesContextImpl) {
 43  1
             return true;
 44  
         }
 45  50
         return false;
 46  
     }
 47  
 
 48  
     /**
 49  
      * Check if the thread is processing render method.
 50  
      * 
 51  
      * @param facesContext
 52  
      * @return
 53  
      */
 54  
     public static boolean isRender(FacesContext facesContext) {
 55  2
         if (isPortlet(facesContext)) {
 56  0
             return facesContext.getExternalContext().getResponse() instanceof RenderResponse;
 57  
         }
 58  2
         return false;
 59  
     }
 60  
 
 61  
 }