felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r889444 - /felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java
Date Thu, 10 Dec 2009 22:29:57 GMT
Author: rickhall
Date: Thu Dec 10 22:29:56 2009
New Revision: 889444

URL: http://svn.apache.org/viewvc?rev=889444&view=rev
Log:
Compare module capabilities.

Modified:
    felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java

Modified: felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java?rev=889444&r1=889443&r2=889444&view=diff
==============================================================================
--- felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java
(original)
+++ felix/sandbox/rickhall/resolver/src/main/java/org/apache/felix/resolver/prototype/ProtoResolver.java
Thu Dec 10 22:29:56 2009
@@ -32,6 +32,7 @@
 import org.apache.felix.resolver.cs.Capability;
 import org.apache.felix.resolver.cs.CapabilitySet;
 import org.apache.felix.resolver.cs.Requirement;
+import org.apache.felix.resolver.manifestparser.Constants;
 
 public class ProtoResolver implements Resolver
 {
@@ -507,25 +508,53 @@
             {
                 Capability cap1 = (Capability) arg1;
                 Capability cap2 = (Capability) arg2;
-                int c = ((Comparable) cap1.getAttribute(Capability.PACKAGE_ATTR).getValue())
-                    .compareTo(cap2.getAttribute(Capability.PACKAGE_ATTR).getValue());
-                if (c == 0)
-                {
-                    Version v1 = (cap1.getAttribute(Capability.VERSION_ATTR) == null)
-                        ? Version.emptyVersion
-                        : (Version) cap1.getAttribute(Capability.VERSION_ATTR).getValue();
-                    Version v2 = (cap1.getAttribute(Capability.VERSION_ATTR) == null)
-                        ? Version.emptyVersion
-                        : (Version) cap1.getAttribute(Capability.VERSION_ATTR).getValue();
-                    // Compare these in reverse order, since we want
-                    // highest version to have priority.
-                    c = v2.compareTo(v1);
+                if (cap1.getNamespace().equals(Capability.MODULE_NAMESPACE))
+                {
+                    int c = ((Comparable) cap1.getAttribute(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE).getValue())
+                        .compareTo(cap2.getAttribute(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE).getValue());
                     if (c == 0)
                     {
-                        c = cap1.getModule().getName().compareTo(cap2.getModule().getName());
+                        Version v1 = (cap1.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE)
== null)
+                            ? Version.emptyVersion
+                            : (Version) cap1.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE).getValue();
+                        Version v2 = (cap1.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE)
== null)
+                            ? Version.emptyVersion
+                            : (Version) cap1.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE).getValue();
+                        // Compare these in reverse order, since we want
+                        // highest version to have priority.
+                        c = v2.compareTo(v1);
+                        if (c == 0)
+                        {
+                            c = cap1.getModule().getName().compareTo(cap2.getModule().getName());
+                        }
+                    }
+                    return c;
+                }
+// TODO: PROTO RESOLVER - Need to change this to handle arbitrary capabilities
+//       that may not have a natural ordering.
+                // Assume everything else is a package capability.
+                else
+                {
+                    int c = ((Comparable) cap1.getAttribute(Capability.PACKAGE_ATTR).getValue())
+                        .compareTo(cap2.getAttribute(Capability.PACKAGE_ATTR).getValue());
+                    if (c == 0)
+                    {
+                        Version v1 = (cap1.getAttribute(Capability.VERSION_ATTR) == null)
+                            ? Version.emptyVersion
+                            : (Version) cap1.getAttribute(Capability.VERSION_ATTR).getValue();
+                        Version v2 = (cap1.getAttribute(Capability.VERSION_ATTR) == null)
+                            ? Version.emptyVersion
+                            : (Version) cap1.getAttribute(Capability.VERSION_ATTR).getValue();
+                        // Compare these in reverse order, since we want
+                        // highest version to have priority.
+                        c = v2.compareTo(v1);
+                        if (c == 0)
+                        {
+                            c = cap1.getModule().getName().compareTo(cap2.getModule().getName());
+                        }
                     }
+                    return c;
                 }
-                return c;
             }
         });
         result.addAll(m_pkgCapSet.match(req.getFilter()));



Mime
View raw message