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/09/21 19:49:04 UTC

svn commit: r817343 - in /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime: Loader.java Main.java Native.java

Author: mturk
Date: Mon Sep 21 17:49:04 2009
New Revision: 817343

URL: http://svn.apache.org/viewvc?rev=817343&view=rev
Log:
Init native when loaded

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Loader.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Loader.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Loader.java?rev=817343&r1=817342&r2=817343&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Loader.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Loader.java Mon Sep 21 17:49:04 2009
@@ -16,6 +16,7 @@
 
 package org.apache.commons.runtime;
 
+import org.apache.commons.runtime.exception.UnsupportedOperatingSystemException;
 import org.apache.commons.runtime.util.Utils;
 
 import java.io.File;
@@ -113,9 +114,11 @@
      * @return {@code true} if the final native library was
      *         loaded.
      */
-    public static boolean loadNatives()
+    public static boolean load()
+        throws UnsupportedOperatingSystemException
     {
         boolean rc = false;
+        String lib = null;
         if (Properties.NATIVE_LIBS != null) {
             for (int i = 0; i < Properties.NATIVE_LIBS.length; i++) {
                 boolean s = Library.load(Properties.NATIVE_LIBS[i]);
@@ -123,11 +126,18 @@
                     /* Record the result of the last entry in the
                      * list of the libraries
                      */
-                    rc = s;
+                    lib = Properties.NATIVE_LIBS[i];
+                    rc  = s;
                 }
             }
         }
-        return rc;
+        if (rc) {
+            /* TODO: Register Windows cleanup
+             */
+            return Native.initialize();
+        }
+        else
+            return false;
     }
 
     /**

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java?rev=817343&r1=817342&r2=817343&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Main.java Mon Sep 21 17:49:04 2009
@@ -36,19 +36,17 @@
      * Dummy main().
      * <p>
      * This class is present only for testing purposes for the moment.
-     * In the future it will be used for launching other Java classes
+     * In the future it will be used for launching other JVM instances
      * from detached JVM.
      * </>
      */
     public static void main(String args[])
     {
         try {
-            boolean loaded = Loader.loadNatives();
-            if (loaded) {
-                Loader.dump();
-            }
-            boolean inited = Native.initialize();
+            boolean inited = Loader.load();
             if (inited) {
+                if (Native.HAS_MAINTAINER_MODE)
+                    Loader.dump();
                 System.out.println("Initialized Apache Commons Runtime : " +
                     Version.MAJOR   + "."  + Version.MINOR     + "."  +
                     Version.PATCH   + " (" + Version.BUILDMARK + ") " + "for " +

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java?rev=817343&r1=817342&r2=817343&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Native.java Mon Sep 21 17:49:04 2009
@@ -54,7 +54,7 @@
      * @throws Throwable in case of error.
      */
     public static boolean initialize()
-        throws Throwable
+        throws UnsupportedOperatingSystemException
     {
         if (!initialized) {
             try {