You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2009/04/21 20:21:04 UTC

svn commit: r767243 - in /commons/sandbox/runtime/trunk/src: main/java/org/apache/commons/runtime/JavaVersion.java test/org/apache/commons/runtime/TestOS.java

Author: mturk
Date: Tue Apr 21 18:21:04 2009
New Revision: 767243

URL: http://svn.apache.org/viewvc?rev=767243&view=rev
Log:
Rename JavaVersion to SystemId

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/JavaVersion.java
    commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestOS.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/JavaVersion.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/JavaVersion.java?rev=767243&r1=767242&r2=767243&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/JavaVersion.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/JavaVersion.java Tue Apr 21 18:21:04 2009
@@ -23,15 +23,20 @@
  * for system name and processor.
  * <p>
  * Used when extracting the native libraries from the .jar to find
- * the correct path of dynamic shared library
+ * the correct path of dynamic shared library and its dependencies.
  * <pre>
  * Constructed path for native libraries:
  *
- * /META-LIB/getSysname()/getProcessor()/&lt;library&gt;
+ * Example for Linux using 64-bit JVM on x86_64 cpu
  *
- * Example for Linux using 64-bit JVM
+ * /META-LIB/200111.loader
+ *      00 ? libcrypto.so
+ *      01 ? libssl.so
+ *      02 ! libacr.so
  *
- * /META-LIB/linux/x86_64/libacr.so
+ * /META-LIB/200111.00.bin  -> /tmp/.unique/libcrypto.so
+ * /META-LIB/200111.01.bin  -> /tmp/.unique/libssl.so
+ * /META-LIB/200111.02.bin  -> /tmp/.unique/libacr.so
  *
  * </pre>
  * </p>
@@ -39,7 +44,7 @@
  * @see OS
  * @since Runtime 1.0
  */
-public final class JavaVersion {
+public final class SystemId {
 
     private Properties props;
 
@@ -52,6 +57,8 @@
 
     /**
      * Name of the operating system implementation.
+     * @return {@code String} representing the operating system 
+     * this {@code JVM} is running on.
      */
     public String getSysname() {
         String name = props.getProperty("os.name");
@@ -78,7 +85,9 @@
     }
 
     /**
-     * Proccessor used.
+     * Name of the operating system proccessor.
+     * @return {@code String} representing the processor
+     * this {@code JVM} is running on.
      */
     public String getProcessor()
     {
@@ -113,4 +122,70 @@
         return cpu;
     }
 
+    /**
+     * Platform Id string.
+     * <p>
+     * Platform Id string is used to name the native libraries inside
+     * {@code META-LIB} jar directory. This resource is then dynamically
+     * extracted to the {@code java.temp.path} or system temporary
+     * directory and then loaded.
+     * </p>
+     * <p>
+     * <b>To be defined</b>
+     * </p>
+     * @return {@code String} representing the JVM platform Id.
+     */
+    public String getPlatformId()
+    {
+        String sys = getSysname();
+        String cpu = getProcessor();
+        String pid;
+
+        if (sys.equals("windows")) {
+			if (cpu.equals("ia32"))
+                pid = "100000";
+			else if (cpu.equals("ia64"))
+                pid = "100011";
+			else
+                pid = "100010";
+        }
+        else if (sys.equals("linux")) {
+			if (cpu.equals("ia32"))
+                pid = "200100";
+			else if (cpu.equals("ia64"))
+                pid = "200112";
+			else
+                pid = "200111";
+        }
+        else if (sys.equals("solaris")) {
+			if (cpu.equals("ia32"))
+                pid = "200200";
+			else if (cpu.equals("sparc32"))
+                pid = "200201";
+			else if (cpu.equals("sparc64"))
+                pid = "200211";
+			else
+                pid = "200210";
+        }
+        else if (sys.equals("darwin")) {
+			if (cpu.equals("ia32"))
+                pid = "200400";
+			else
+                pid = "200201";
+        }
+        else if (sys.equals("hpux")) {
+			if (cpu.equals("ia32"))
+                pid = "200800";
+			else if (cpu.equals("ia64"))
+                pid = "200811";
+			else if (cpu.equals("pa32"))
+                pid = "200802";
+			else
+                pid = "200812";
+        }
+        else {
+            pid = "000000";
+        }
+        return pid;
+    }
 }

Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestOS.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestOS.java?rev=767243&r1=767242&r2=767243&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestOS.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestOS.java Tue Apr 21 18:21:04 2009
@@ -59,10 +59,11 @@
         System.out.println("Data Model " + OS.getDataModel());
         System.out.println("Hardware   " + OS.getHardwarePlatform());
         System.out.println();
-        JavaVersion v = new JavaVersion();
-        System.out.println("Java Version:");
+        SystemId v = new  SystemId();
+        System.out.println("System Id:");
         System.out.println("Name       " + v.getSysname());
         System.out.println("Processor  " + v.getProcessor());
+        System.out.println("Id         " + v.getPlatformId());
         System.out.println();
         System.out.println("Library Version:");
         System.out.println("Major      " + Version.MAJOR);