1 17 package org.apache.geronimo.system.configuration.condition; 18 19 import org.apache.commons.logging.Log; 20 import org.apache.commons.logging.LogFactory; 21 22 27 public class JavaVariable 28 { 29 private static final Log log = LogFactory.getLog(JavaVariable.class); 30 31 public String getVendor() { 32 return SystemUtils.JAVA_VENDOR; 33 } 34 35 public String getVresion() { 36 return SystemUtils.JAVA_VERSION; 37 } 38 39 public String getVmVendor() { 40 return SystemUtils.JAVA_VM_VENDOR; 41 } 42 43 public String getVmVersion() { 44 return SystemUtils.JAVA_VM_VERSION; 45 } 46 47 public boolean getIs1_1() { 48 return SystemUtils.IS_JAVA_1_1; 49 } 50 51 public boolean getIs1_2() { 52 return SystemUtils.IS_JAVA_1_2; 53 } 54 55 public boolean getIs1_3() { 56 return SystemUtils.IS_JAVA_1_3; 57 } 58 59 public boolean getIs1_4() { 60 return SystemUtils.IS_JAVA_1_4; 61 } 62 63 public boolean getIs1_5() { 64 return SystemUtils.IS_JAVA_1_5; 65 } 66 67 public boolean getIs1_6() { 68 return SystemUtils.IS_JAVA_1_6; 69 } 70 71 public boolean getIsVersionAtLeast(final float requiredVersion) { 72 return SystemUtils.isJavaVersionAtLeast(requiredVersion); 73 } 74 75 public boolean getIsVersionAtLeast(final int requiredVersion) { 76 return SystemUtils.isJavaVersionAtLeast(requiredVersion); 77 } 78 79 public boolean getVersionMatches(String version) { 80 version = version.trim(); 81 82 boolean debug = log.isDebugEnabled(); 83 boolean result = false; 84 85 if (version.endsWith("*")) { 86 version = version.substring(0, version.length() - 1).trim(); 87 88 if (debug) { 89 log.debug("Checking Java version is in the same group as: " + version); 90 } 91 92 String tmp = SystemUtils.JAVA_VERSION_TRIMMED; 93 94 if (debug) { 95 log.debug("Requested version: " + tmp); 96 log.debug("JVM version: " + SystemUtils.JAVA_VERSION_FLOAT); 97 } 98 99 result = tmp.startsWith(version); 100 } 101 else if (version.endsWith("+")) { 102 version = version.substring(0, version.length() - 1).trim(); 103 104 if (debug) { 105 log.debug("Checking Java version is greater than: " + version); 106 } 107 108 float tmp = Float.parseFloat(version); 109 110 if (debug) { 111 log.debug("Requested version: " + tmp); 112 log.debug("JVM version: " + SystemUtils.JAVA_VERSION_FLOAT); 113 } 114 115 result = tmp <= SystemUtils.JAVA_VERSION_FLOAT; 116 } 117 else { 118 if (debug) { 119 log.debug("Checking Java version is equal to: " + version); 120 } 121 122 float tmp = Float.parseFloat(version); 123 124 if (debug) { 125 log.debug("Requested version: " + tmp); 126 log.debug("JVM version: " + SystemUtils.JAVA_VERSION_FLOAT); 127 } 128 129 result = tmp == SystemUtils.JAVA_VERSION_FLOAT; 130 } 131 132 return result; 133 } 134 } 135 | Popular Tags |