2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 super();
35 }
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 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 if (activeRuntime > 0) {
66 return activeRuntime;
67 }
68 try {
69
70 Class.forName("com.sun.faces.config.JSFVersionTracker");
71 activeRuntime = RI_1_2;
72 } catch (ClassNotFoundException e1) {
73 try {
74 Class.forName("org.apache.myfaces.application.jsp.JspViewHandlerImpl");
75 activeRuntime = MYFACES_1_1;
76 } catch (ClassNotFoundException e2) {
77 activeRuntime = RI_1_1;
78 }
79 }
80
81 return activeRuntime;
82 }
83 }