geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jdil...@apache.org
Subject svn commit: r454037 - /geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/condition/JavaVariable.java
Date Sat, 07 Oct 2006 22:26:52 GMT
Author: jdillon
Date: Sat Oct  7 15:26:46 2006
New Revision: 454037

URL: http://svn.apache.org/viewvc?view=rev&rev=454037
Log:
(GERONIMO-2463) Added java.versionMatches() which provides OSX-like version matching

Modified:
    geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/condition/JavaVariable.java

Modified: geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/condition/JavaVariable.java
URL: http://svn.apache.org/viewvc/geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/condition/JavaVariable.java?view=diff&rev=454037&r1=454036&r2=454037
==============================================================================
--- geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/condition/JavaVariable.java
(original)
+++ geronimo/server/trunk/modules/geronimo-system/src/main/java/org/apache/geronimo/system/configuration/condition/JavaVariable.java
Sat Oct  7 15:26:46 2006
@@ -19,6 +19,9 @@
 
 package org.apache.geronimo.system.configuration.condition;
 
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
 /**
  * Provides access to Java version details for use in condition expressions.
  *
@@ -26,6 +29,8 @@
  */
 public class JavaVariable
 {
+    private static final Log log = LogFactory.getLog(JavaVariable.class);
+    
     public String getVendor() {
         return SystemUtils.JAVA_VENDOR;
     }
@@ -66,11 +71,67 @@
         return SystemUtils.IS_JAVA_1_6;
     }
 
-    public boolean isVersionAtLeast(final float requiredVersion) {
+    public boolean getIsVersionAtLeast(final float requiredVersion) {
         return SystemUtils.isJavaVersionAtLeast(requiredVersion);
     }
 
-    public boolean isVersionAtLeast(final int requiredVersion) {
+    public boolean getIsVersionAtLeast(final int requiredVersion) {
         return SystemUtils.isJavaVersionAtLeast(requiredVersion);
+    }
+    
+    public boolean getVersionMatches(String version) {
+        version = version.trim();
+        
+        boolean debug = log.isDebugEnabled();
+        boolean result = false;
+        
+        if (version.endsWith("*")) {
+            version = version.substring(0, version.length() - 1).trim();
+            
+            if (debug) {
+                log.debug("Checking Java version is in the same group as: " + version);
+            }
+            
+            String tmp = SystemUtils.JAVA_VERSION_TRIMMED;
+            
+            if (debug) {
+                log.debug("Requested version: " + tmp);
+                log.debug("JVM version: " + SystemUtils.JAVA_VERSION_FLOAT);
+            }
+            
+            result = tmp.startsWith(version);
+        }
+        else if (version.endsWith("+")) {
+            version = version.substring(0, version.length() - 1).trim();
+            
+            if (debug) {
+                log.debug("Checking Java version is greater than: " + version);
+            }
+            
+            float tmp = Float.parseFloat(version);
+            
+            if (debug) {
+                log.debug("Requested version: " + tmp);
+                log.debug("JVM version: " + SystemUtils.JAVA_VERSION_FLOAT);
+            }
+            
+            result = tmp <= SystemUtils.JAVA_VERSION_FLOAT;
+        }
+        else {
+            if (debug) {
+                log.debug("Checking Java version is equal to: " + version);
+            }
+            
+            float tmp = Float.parseFloat(version);
+            
+            if (debug) {
+                log.debug("Requested version: " + tmp);
+                log.debug("JVM version: " + SystemUtils.JAVA_VERSION_FLOAT);
+            }
+            
+            result = tmp == SystemUtils.JAVA_VERSION_FLOAT;
+        }
+        
+        return result;
     }
 }



Mime
View raw message