commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r817744 - /commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Loader.java
Date Tue, 22 Sep 2009 17:48:32 GMT
Author: mturk
Date: Tue Sep 22 17:48:32 2009
New Revision: 817744

URL: http://svn.apache.org/viewvc?rev=817744&view=rev
Log:
Load module only if initialized already

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Loader.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=817744&r1=817743&r2=817744&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 Tue
Sep 22 17:48:32 2009
@@ -151,7 +151,7 @@
                 boolean s = Library.load(Properties.NATIVE_LIBS[i]);
                 if (i == (Properties.NATIVE_LIBS.length - 1)) {
                     /* Record the result of the last entry in the
-                     * list of the libraries
+                     * library dependency list (library itself).
                      */
                     rc  = s;
                 }
@@ -173,26 +173,39 @@
     public static boolean load(String module)
         throws UnsupportedOperatingSystemException
     {
+        if (!isLoaded) {
+            /* Cannot load module if main library wasn't initialized.
+             */
+            return false;
+        }
         if (mods.containsKey(module))
             return true;
 
+        byte cnt = 0;
         boolean rc = false;
         String [] md = Properties.getArray("library.load." + module, null);
-        if (md != null) {
+        if (md == null) {
+            /* Not listed inside .properties file
+             */
+            rc = Library.load(module);
+            cnt++;
+        }
+        else {
             for (int i = 0; i < md.length; i++) {
                 boolean s = Library.load(md[i]);
                 if (i == (md.length - 1)) {
                     /* Record the result of the last entry in the
-                     * list of the libraries
+                     * module dependency list (module itself).
                      */
                     rc  = s;
                 }
+                cnt++;
             }
         }
         if (rc) {
             /* Add the module to the list of loaded modules.
              */
-            mods.put(module, null);
+            mods.put(module, new Byte(cnt));
             return true;
         }
         else



Mime
View raw message