2009/05/20 - Apache Shale has been retired.

For more information, please explore the Attic.

Coverage Report - org.apache.shale.clay.utils.JSFRuntimeTracker
 
Classes in this File Line Coverage Branch Coverage Complexity
JSFRuntimeTracker
0% 
0% 
3
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one or more
 3  
  * contributor license agreements.  See the NOTICE file distributed with
 4  
  * this work for additional information regarding copyright ownership.
 5  
  * The ASF licenses this file to you under the Apache License, Version 2.0
 6  
  * (the "License"); you may not use this file except in compliance with
 7  
  * the License.  You may obtain a copy of the License at
 8  
  *
 9  
  *      http://www.apache.org/licenses/LICENSE-2.0
 10  
  *
 11  
  * Unless required by applicable law or agreed to in writing, software
 12  
  * distributed under the License is distributed on an "AS IS" BASIS,
 13  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 14  
  * See the License for the specific language governing permissions and
 15  
  * limitations under the License.
 16  
  */
 17  
 
 18  
 /*
 19  
  * $Id: JSFRuntimeTracker.java 465411 2006-10-18 23:06:50Z gvanmatre $
 20  
  */
 21  
 
 22  
 package org.apache.shale.clay.utils;
 23  
 
 24  
 /**
 25  
  * <p>This utility class is used to determine the
 26  
  * JSF runtime that will take presidency.</p>
 27  
  */
 28  
 public final class JSFRuntimeTracker {
 29  
 
 30  
     /**
 31  
      * <p>Utility Class hides the default constructor.</p>
 32  
      */
 33  
     private JSFRuntimeTracker() {
 34  0
         super();
 35  0
     }
 36  
 
 37  
     /**
 38  
      * <p>This enumeration indicates the JSF RI 1.1.x runtime is installed.</p>
 39  
      */
 40  
     public static final int RI_1_1 = 0;
 41  
 
 42  
     /**
 43  
      * <p>This enumeration indicates the MyFaces 1.1.x runtime is installed.</p>
 44  
      */
 45  
     public static final int MYFACES_1_1 = 1;
 46  
 
 47  
     /**
 48  
      * <p>This enumeration indicates the JSF RI 1.2.x runtime is installed.</p>
 49  
      */
 50  
     public static final int RI_1_2 = 2;
 51  
 
 52  
     /**
 53  
      * <p>Captures the active runtime once determined.</p>
 54  
      */
 55  0
     private static int activeRuntime = -1;
 56  
 
 57  
     /**
 58  
      * <p>This method will try to load some key classes in the various runtimes
 59  
      * to determine the active runtime.  The enumerations are as follows:
 60  
      * <code>RI_1_1</code>, <code>MYFACES_1_1</code>, <code>RI_1_2</code>.</p>
 61  
      *
 62  
      * @return an enumeration that indicates the active JSF runtime
 63  
      */
 64  
     public static int getJsfRuntime() {
 65  0
         if (activeRuntime > 0) {
 66  0
             return activeRuntime;
 67  
         }
 68  
         try {
 69  
             // JSF RI 1.2
 70  0
             Class.forName("com.sun.faces.config.JSFVersionTracker");
 71  0
             activeRuntime = RI_1_2;
 72  0
         } catch (ClassNotFoundException e1) {
 73  
             try {
 74  0
                 Class.forName("org.apache.myfaces.application.jsp.JspViewHandlerImpl");
 75  0
                 activeRuntime = MYFACES_1_1;  //myfaces 1.1.x
 76  0
             } catch (ClassNotFoundException e2) {
 77  0
                 activeRuntime = RI_1_1; //JSF RI 1.1
 78  0
             }
 79  0
         }
 80  
 
 81  0
         return activeRuntime;
 82  
     }
 83  
 }