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/22 19:24:34 UTC
svn commit: r817737 - in /commons/sandbox/runtime/trunk/src:
main/java/org/apache/commons/runtime/ test/org/apache/commons/runtime/
Author: mturk
Date: Tue Sep 22 17:24:33 2009
New Revision: 817737
URL: http://svn.apache.org/viewvc?rev=817737&view=rev
Log:
Add module support to Loader
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/Properties.java
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestCallback.java
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestChildMain.java
commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.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=817737&r1=817736&r2=817737&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:24:33 2009
@@ -34,6 +34,7 @@
{
private static HashMap<String, File> libs;
+ private static HashMap<String, Byte> mods;
private static File path = null;
private static boolean isLoaded = false;
@@ -44,6 +45,7 @@
static {
libs = new HashMap<String, File>();
+ mods = new HashMap<String, Byte>();
}
/**
@@ -166,6 +168,38 @@
}
/**
+ * Load module.
+ */
+ public static boolean load(String module)
+ throws UnsupportedOperatingSystemException
+ {
+ if (mods.containsKey(module))
+ return true;
+
+ boolean rc = false;
+ String [] md = Properties.getArray("library.load." + module, null);
+ if (md != null) {
+ for (int i = 0; i < Properties.NATIVE_LIBS.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
+ */
+ rc = s;
+ }
+ }
+ }
+ if (rc) {
+ /* Add the module to the list of loaded modules.
+ */
+ mods.put(module, null);
+ return true;
+ }
+ else
+ return false;
+ }
+
+ /**
* Temporary debug method that dumps loaded natives to stdout.
*/
@Deprecated
Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Properties.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Properties.java?rev=817737&r1=817736&r2=817737&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Properties.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/Properties.java Tue Sep 22 17:24:33 2009
@@ -154,6 +154,17 @@
else
return null;
}
+
+ public static String[] getArray(String key, String def)
+ {
+ String [] rv = getA(key);
+ if (rv == null && def != null) {
+ rv = new String[1];
+ rv[0] = def;
+ }
+ return rv;
+ }
+
//
// Cpu info section.
//
Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestCallback.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestCallback.java?rev=817737&r1=817736&r2=817737&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestCallback.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestCallback.java Tue Sep 22 17:24:33 2009
@@ -71,7 +71,7 @@
protected void setUp()
throws Exception
{
- System.loadLibrary("acr");
+ Loader.load();
}
public void testSimpleCallback()
Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestChildMain.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestChildMain.java?rev=817737&r1=817736&r2=817737&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestChildMain.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestChildMain.java Tue Sep 22 17:24:33 2009
@@ -40,8 +40,8 @@
{
Loader.load();
if (OpenSSL.SUPPORTED) {
- // Load the ssl library if compiled in
- System.loadLibrary("acrssl");
+ // Load the ssl module library if compiled in
+ Loader.load("ssl");
}
}
Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java?rev=817737&r1=817736&r2=817737&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java Tue Sep 22 17:24:33 2009
@@ -135,8 +135,8 @@
}
longString = new String(longChar);
if (OpenSSL.SUPPORTED) {
- // Load the ssl library if compiled in
- System.loadLibrary("acrssl");
+ // Load the ssl module library if compiled in
+ Loader.load("ssl");
}
}