felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1064871 - in /felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/util/manifestparser: ManifestParser.java R4Library.java
Date Fri, 28 Jan 2011 20:57:34 GMT
Author: rickhall
Date: Fri Jan 28 20:57:33 2011
New Revision: 1064871

URL: http://svn.apache.org/viewvc?rev=1064871&view=rev
Log:
Port FELIX-2789 from trunk to 3.0.8 branch.

Modified:
    felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
    felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/util/manifestparser/R4Library.java

Modified: felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
URL: http://svn.apache.org/viewvc/felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java?rev=1064871&r1=1064870&r2=1064871&view=diff
==============================================================================
--- felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
(original)
+++ felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
Fri Jan 28 20:57:33 2011
@@ -1516,7 +1516,7 @@ public class ManifestParser
      * included in the set of delimiter characters.
      * @param value the delimited string to parse.
      * @param delim the characters delimiting the tokens.
-     * @return an array of string tokens or null if there were no tokens.
+     * @return a list of string or an empty list if there are none.
     **/
     public static List<String> parseDelimitedString(String value, String delim)
     {

Modified: felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/util/manifestparser/R4Library.java
URL: http://svn.apache.org/viewvc/felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/util/manifestparser/R4Library.java?rev=1064871&r1=1064870&r2=1064871&view=diff
==============================================================================
--- felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/util/manifestparser/R4Library.java
(original)
+++ felix/branches/org.apache.felix.framework-3.0.8-RC/src/main/java/org/apache/felix/framework/util/manifestparser/R4Library.java
Fri Jan 28 20:57:33 2011
@@ -18,6 +18,7 @@
  */
 package org.apache.felix.framework.util.manifestparser;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import org.osgi.framework.Constants;
@@ -84,45 +85,52 @@ public class R4Library
     **/
     public boolean match(Map configMap, String name)
     {
+        // First, check for an exact match.
+        boolean matched = false;
+        if (m_libraryFile.equals(name) || m_libraryFile.endsWith("/" + name))
+        {
+            matched = true;
+        }
+
+        // Then check the mapped name.
         String libname = System.mapLibraryName(name);
+        // As well as any additional library file extensions.
         List<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
+        if (exts == null)
         {
+            exts = new ArrayList<String>();
+        }
+        // For Mac OSX, try dylib too.
+        if (libname.endsWith(".jnilib") && m_libraryFile.endsWith(".dylib"))
+        {
+            exts.add("dylib");
+        }
+        // Loop until we find a match or not.
+        int extIdx = -1;
+        while (!matched && (extIdx < exts.size()))
+        {
+            // Check if the current name matches.
             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;
+                matched = true;
             }
 
+            // Increment extension index.
+            extIdx++;
+
             // If we have other native library extensions to try, then
             // calculate the new native library name.
-            if ((exts != null) && (extIdx < exts.size()))
+            if (!matched && (extIdx < exts.size()))
             {
                 int idx = libname.lastIndexOf(".");
                 libname = (idx < 0)
-                    ? libname + "." + exts.get(extIdx++)
-                    : libname.substring(0, idx) + "." + exts.get(extIdx++);
+                    ? libname + "." + exts.get(extIdx)
+                    : libname.substring(0, idx + 1) + exts.get(extIdx);
             }
         }
-        while ((exts != null) && (extIdx < exts.size()));
 
-        return false;
+        return matched;
     }
 
     public String toString()
@@ -172,4 +180,4 @@ public class R4Library
         }
         return "*";
     }
-}
\ No newline at end of file
+}



Mime
View raw message