felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r790963 - in /felix/trunk/framework/src/main/java/org/apache/felix/framework: ModuleImpl.java util/manifestparser/R4Library.java
Date Fri, 03 Jul 2009 16:31:09 GMT
Author: rickhall
Date: Fri Jul  3 16:31:09 2009
New Revision: 790963

URL: http://svn.apache.org/viewvc?rev=790963&view=rev
Log:
Add support for configurable native library extensions. (FELIX-1298)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java
    felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Library.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java?rev=790963&r1=790962&r2=790963&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ModuleImpl.java Fri Jul
 3 16:31:09 2009
@@ -1876,7 +1876,7 @@
             R4Library[] libs = getNativeLibraries();
             for (int i = 0; (libs != null) && (i < libs.length); i++)
             {
-                if (libs[i].match(name))
+                if (libs[i].match(m_configMap, name))
                 {
                     return getContent().getEntryAsNativeLibrary(libs[i].getEntryName());
                 }

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Library.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Library.java?rev=790963&r1=790962&r2=790963&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Library.java
(original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/util/manifestparser/R4Library.java
Fri Jul  3 16:31:09 2009
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.framework.util.manifestparser;
 
+import java.util.Map;
 import org.osgi.framework.Constants;
 
 public class R4Library
@@ -80,26 +81,41 @@
      * @return <tt>true</tt> if this native library name matches this native
      *         library definition; <tt>false</tt> otherwise.
     **/
-    public boolean match(String name)
+    public boolean match(Map configMap, String name)
     {
         String libname = System.mapLibraryName(name);
-        if (m_libraryFile.equals(libname) || m_libraryFile.endsWith("/" + libname))
+        String[] exts = ManifestParser.parseDelimitedString(
+            (String) configMap.get(Constants.FRAMEWORK_LIBRARY_EXTENSIONS), ",");
+        int extIdx = 0;
+
+        // First try to match the default name, then try to match any additionally
+        // specified library extensions.
+        do
         {
-            return true;
-        }
-        else if (libname.endsWith(".jnilib") &&
-            m_libraryFile.endsWith(".dylib"))
-        {
-            libname = libname.substring(0, libname.length() - 6) + "dylib";
             if (m_libraryFile.equals(libname) || m_libraryFile.endsWith("/" + libname))
             {
                 return true;
             }
+            else if (libname.endsWith(".jnilib") && m_libraryFile.endsWith(".dylib"))
+            {
+                libname = libname.substring(0, libname.length() - 6) + "dylib";
+                if (m_libraryFile.equals(libname) || m_libraryFile.endsWith("/" + libname))
+                {
+                    return true;
+                }
+            }
+            else if (m_libraryFile.equals(name) || m_libraryFile.endsWith("/" + name))
+            {
+                return true;
+            }
+
+            int idx = libname.lastIndexOf(".");
+            libname = (idx < 0)
+                ? libname + "." + exts[extIdx++]
+                : libname.substring(0, idx) + "." + exts[extIdx++];
         }
-        else if (m_libraryFile.equals(name) || m_libraryFile.endsWith("/" + name))
-        {
-            return true;
-        }
+        while ((exts != null) && (extIdx < exts.length));
+
         return false;
     }
 



Mime
View raw message