You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by ri...@apache.org on 2011/10/21 19:07:07 UTC

svn commit: r1187468 [1/2] - in /felix/sandbox/rickhall/framework-r5: ./ src/main/java/org/apache/felix/framework/ src/main/java/org/apache/felix/framework/capabilityset/ src/main/java/org/apache/felix/framework/util/ src/main/java/org/apache/felix/fra...

Author: rickhall
Date: Fri Oct 21 17:07:06 2011
New Revision: 1187468

URL: http://svn.apache.org/viewvc?rev=1187468&view=rev
Log:
Modify framework to use OBR resolver. Still need to get dynamic
imports working.

Modified:
    felix/sandbox/rickhall/framework-r5/pom.xml
    felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleRevisionDependencies.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/Felix.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/ServiceRegistry.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/StatefulResolver.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/util/Util.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/wiring/BundleCapabilityImpl.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/wiring/BundleRequirementImpl.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/wiring/CandidateComparator.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleCapability.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleRequirement.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleRevision.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleWire.java
    felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleWiring.java

Modified: felix/sandbox/rickhall/framework-r5/pom.xml
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/pom.xml?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/pom.xml (original)
+++ felix/sandbox/rickhall/framework-r5/pom.xml Fri Oct 21 17:07:06 2011
@@ -29,6 +29,11 @@
   <artifactId>org.apache.felix.framework</artifactId>
   <version>4.1.0-SNAPSHOT</version>
   <dependencies>
+    <dependency>
+      <groupId>org.apache.felix</groupId>
+      <artifactId>org.apache.felix.resolver</artifactId>
+      <version>0.1.0-SNAPSHOT</version>
+    </dependency>
   </dependencies>
   <properties>
     <dollar>$</dollar>
@@ -61,7 +66,7 @@
             <Bundle-Description>OSGi R4 framework implementation.</Bundle-Description>
             <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
             <Export-Package>org.osgi.framework.*;-split-package:=merge-first,org.osgi.service.packageadmin,org.osgi.service.url,org.osgi.service.startlevel,org.osgi.util.tracker</Export-Package>
-            <Private-Package>org.apache.felix.framework.*</Private-Package>
+            <Private-Package>org.apache.felix.framework.*,org.apache.felix.resolver.*,org.osgi.framework.resource.*,org.osgi.service.resolver.*</Private-Package>
             <Import-Package>!*</Import-Package>
           </instructions>
         </configuration>

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleRevisionDependencies.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleRevisionDependencies.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleRevisionDependencies.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleRevisionDependencies.java Fri Oct 21 17:07:06 2011
@@ -41,9 +41,7 @@ class BundleRevisionDependencies
 
     public synchronized void addDependent(BundleWire bw)
     {
-// TODO: OSGi R4.4 - Eventually we won't need to use the impl type here,
-//       since the plan is to standardize on this method for the OBR spec.
-        BundleRevision provider = ((BundleWireImpl) bw).getProvider();
+        BundleRevision provider = (BundleRevision) bw.getProvider();
         Map<BundleCapability, Set<BundleWire>> caps =
             m_dependentsMap.get(provider);
         if (caps == null)
@@ -186,10 +184,7 @@ class BundleRevisionDependencies
                     {
                         for (BundleWire dependentWire : entry.getValue())
                         {
-// TODO: OSGi R4.4 - Eventually we won't need to use the impl type here,
-//       since the plan is to standardize on this method for the OBR spec.
-                            result.add(((BundleWireImpl) dependentWire)
-                                .getRequirer().getBundle());
+                            result.add(dependentWire.getRequirerWiring().getBundle());
                         }
                     }
                 }
@@ -227,10 +222,7 @@ class BundleRevisionDependencies
                     {
                         for (BundleWire dependentWire : entry.getValue())
                         {
-// TODO: OSGi R4.4 - Eventually we won't need to use the impl type here,
-//       since the plan is to standardize on this method for the OBR spec.
-                            result.add(((BundleWireImpl) dependentWire)
-                                .getRequirer().getBundle());
+                            result.add(dependentWire.getRequirerWiring().getBundle());
                         }
                     }
                 }
@@ -260,10 +252,7 @@ class BundleRevisionDependencies
                     {
                         for (BundleWire dependentWire : entry.getValue())
                         {
-// TODO: OSGi R4.4 - Eventually we won't need to use the impl type here,
-//       since the plan is to standardize on this method for the OBR spec.
-                            result.add(((BundleWireImpl) dependentWire)
-                                .getRequirer().getBundle());
+                            result.add(dependentWire.getRequirerWiring().getBundle());
                         }
                     }
                 }
@@ -284,10 +273,8 @@ class BundleRevisionDependencies
             {
                 for (BundleWire bw : wiring.getRequiredWires(null))
                 {
-// TODO: OSGi R4.4 - Eventually we won't need to use the impl type here,
-//       since the plan is to standardize on this method for the OBR spec.
                     Map<BundleCapability, Set<BundleWire>> caps =
-                        m_dependentsMap.get(((BundleWireImpl) bw).getProvider());
+                        m_dependentsMap.get(bw.getProviderWiring().getRevision());
                     if (caps != null)
                     {
                         List<BundleCapability> gc = new ArrayList<BundleCapability>();
@@ -306,9 +293,7 @@ class BundleRevisionDependencies
                         }
                         if (caps.isEmpty())
                         {
-// TODO: OSGi R4.4 - Eventually we won't need to use the impl type here,
-//       since the plan is to standardize on this method for the OBR spec.
-                            m_dependentsMap.remove(((BundleWireImpl) bw).getProvider());
+                            m_dependentsMap.remove(bw.getProviderWiring().getRevision());
                         }
                     }
                 }

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleRevisionImpl.java Fri Oct 21 17:07:06 2011
@@ -22,7 +22,6 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.net.URLStreamHandler;
 import java.security.ProtectionDomain;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -39,6 +38,8 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
+import org.osgi.framework.resource.Capability;
+import org.osgi.framework.resource.Requirement;
 import org.osgi.framework.wiring.BundleCapability;
 import org.osgi.framework.wiring.BundleRequirement;
 import org.osgi.framework.wiring.BundleRevision;
@@ -189,6 +190,16 @@ public class BundleRevisionImpl implemen
         return m_version;
     }
 
+    public List<Capability> getCapabilities(String namespace)
+    {
+        return asCapabilityList(getDeclaredCapabilities(namespace));
+    }
+
+    private static List<Capability> asCapabilityList(List<? extends Capability> orig)
+    {
+        return (List<Capability>) orig;
+    }
+
     public List<BundleCapability> getDeclaredCapabilities(String namespace)
     {
         List<BundleCapability> result = m_declaredCaps;
@@ -206,6 +217,16 @@ public class BundleRevisionImpl implemen
         return result;
     }
 
+    public List<Requirement> getRequirements(String namespace)
+    {
+        return asRequirementList(getDeclaredRequirements(namespace));
+    }
+
+    private static List<Requirement> asRequirementList(List<? extends Requirement> orig)
+    {
+        return (List<Requirement>) orig;
+    }
+
     public List<BundleRequirement> getDeclaredRequirements(String namespace)
     {
         List<BundleRequirement> result = m_declaredReqs;

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleWiringImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleWiringImpl.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleWiringImpl.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/BundleWiringImpl.java Fri Oct 21 17:07:06 2011
@@ -44,7 +44,6 @@ import java.util.TreeSet;
 import org.apache.felix.framework.cache.Content;
 import org.apache.felix.framework.cache.JarContent;
 import org.apache.felix.framework.capabilityset.SimpleFilter;
-import org.apache.felix.framework.resolver.ResolveException;
 import org.apache.felix.framework.util.CompoundEnumeration;
 import org.apache.felix.framework.util.FelixConstants;
 import org.apache.felix.framework.util.SecurityManagerEx;
@@ -62,11 +61,17 @@ import org.osgi.framework.PackagePermiss
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.hooks.weaving.WeavingException;
 import org.osgi.framework.hooks.weaving.WeavingHook;
+import org.osgi.framework.resource.Capability;
+import org.osgi.framework.resource.Requirement;
+import org.osgi.framework.resource.Resource;
+import org.osgi.framework.resource.ResourceConstants;
+import org.osgi.framework.resource.Wire;
 import org.osgi.framework.wiring.BundleCapability;
 import org.osgi.framework.wiring.BundleRequirement;
 import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.framework.wiring.BundleWire;
 import org.osgi.framework.wiring.BundleWiring;
+import org.osgi.service.resolver.ResolutionException;
 
 public class BundleWiringImpl implements BundleWiring
 {
@@ -260,8 +265,6 @@ public class BundleWiringImpl implements
             new HashMap<String, List<List<String>>>();
         Map<String, List<List<String>>> excludedPkgFilters =
             new HashMap<String, List<List<String>>>();
-// TODO: OSGi R4.4 - Fragments currently have no capabilities, but they may
-//       have an identity capability in the future.
         if (!isFragment)
         {
             for (BundleCapability cap : m_revision.getDeclaredCapabilities(null))
@@ -304,9 +307,8 @@ public class BundleWiringImpl implements
                 {
                     for (BundleCapability cap : fragment.getDeclaredCapabilities(null))
                     {
-// TODO: OSGi R4.4 - OSGi R4.4 may introduce an identity capability, if so
-//       that will need to be excluded from here.
-                        if (!cap.getNamespace().equals(BundleRevision.PACKAGE_NAMESPACE)
+                        if (!cap.getNamespace().equals(ResourceConstants.IDENTITY_NAMESPACE)
+                            && !cap.getNamespace().equals(BundleRevision.PACKAGE_NAMESPACE)
                             || (cap.getNamespace().equals(BundleRevision.PACKAGE_NAMESPACE)
                                 && !imports.contains(cap.getAttributes()
                                     .get(BundleRevision.PACKAGE_NAMESPACE).toString())))
@@ -489,6 +491,31 @@ public class BundleWiringImpl implements
         return !m_isDisposed;
     }
 
+    public Bundle getBundle()
+    {
+        return m_revision.getBundle();
+    }
+
+    public Resource getResource()
+    {
+        return m_revision;
+    }
+
+    public BundleRevision getRevision()
+    {
+        return m_revision;
+    }
+
+    public List<Capability> getResourceCapabilities(String namespace)
+    {
+        return asCapabilityList(getCapabilities(namespace));
+    }
+
+    private static List<Capability> asCapabilityList(List<? extends Capability> orig)
+    {
+        return (List<Capability>) orig;
+    }
+
     public List<BundleCapability> getCapabilities(String namespace)
     {
         if (isInUse())
@@ -510,6 +537,16 @@ public class BundleWiringImpl implements
         return null;
     }
 
+    public List<Requirement> getResourceRequirements(String namespace)
+    {
+        return asRequirementList(getRequirements(namespace));
+    }
+
+    private static List<Requirement> asRequirementList(List<? extends Requirement> orig)
+    {
+        return (List<Requirement>) orig;
+    }
+
     public List<BundleRequirement> getRequirements(String namespace)
     {
         if (isInUse())
@@ -546,6 +583,16 @@ public class BundleWiringImpl implements
         return m_resolvedNativeLibs;
     }
 
+    public List<Wire> getProvidedResourceWires(String namespace)
+    {
+        return asWireList(getProvidedWires(namespace));
+    }
+
+    private static List<Wire> asWireList(List<? extends Wire> orig)
+    {
+        return (List<Wire>) orig;
+    }
+
     public List<BundleWire> getProvidedWires(String namespace)
     {
         if (isInUse())
@@ -556,6 +603,11 @@ public class BundleWiringImpl implements
         return null;
     }
 
+    public List<Wire> getRequiredResourceWires(String namespace)
+    {
+        return asWireList(getRequiredWires(namespace));
+    }
+
     public List<BundleWire> getRequiredWires(String namespace)
     {
         if (isInUse())
@@ -596,11 +648,6 @@ public class BundleWiringImpl implements
         m_importedPkgs = importedPkgs;
     }
 
-    public BundleRevision getRevision()
-    {
-        return m_revision;
-    }
-
     public synchronized ClassLoader getClassLoader()
     {
         if (m_isDisposed)
@@ -984,11 +1031,6 @@ public class BundleWiringImpl implements
         return SimpleFilter.compareSubstring(pattern, resource);
     }
 
-    public Bundle getBundle()
-    {
-        return m_revision.getBundle();
-    }
-
     //
     // Class loader implementation methods.
     //
@@ -1138,7 +1180,7 @@ public class BundleWiringImpl implements
             {
                 provider = m_resolver.resolve(m_revision, pkgName);
             }
-            catch (ResolveException ex)
+            catch (ResolutionException ex)
             {
                 // Ignore this since it is likely normal.
             }
@@ -1537,7 +1579,7 @@ public class BundleWiringImpl implements
         {
             provider = m_resolver.resolve(m_revision, pkgName);
         }
-        catch (ResolveException ex)
+        catch (ResolutionException ex)
         {
             // Ignore this since it is likely normal.
         }
@@ -2526,7 +2568,7 @@ public class BundleWiringImpl implements
                 BundleRevision.PACKAGE_NAMESPACE, (Object) pkgName);
             BundleRequirementImpl req = new BundleRequirementImpl(
                 revision, BundleRevision.PACKAGE_NAMESPACE, dirs, attrs);
-            Set<BundleCapability> exporters = resolver.getCandidates(req, false);
+            Set<Capability> exporters = resolver.findCandidates(req, false);
 
             BundleRevision provider = null;
             try
@@ -2539,7 +2581,8 @@ public class BundleWiringImpl implements
             }
 
             String exporter = (exporters.isEmpty())
-                ? null : exporters.iterator().next().getRevision().getBundle().toString();
+                ? null
+                : ((BundleCapability) exporters.iterator().next()).getRevision().getBundle().toString();
 
             StringBuffer sb = new StringBuffer("*** Class '");
             sb.append(name);
@@ -2565,7 +2608,7 @@ public class BundleWiringImpl implements
             BundleRevision.PACKAGE_NAMESPACE, (Object) pkgName);
         BundleRequirementImpl req = new BundleRequirementImpl(
             revision, BundleRevision.PACKAGE_NAMESPACE, dirs, attrs);
-        Set<BundleCapability> exports = resolver.getCandidates(req, false);
+        Set<Capability> exports = resolver.findCandidates(req, false);
         if (exports.size() > 0)
         {
             boolean classpath = false;
@@ -2584,7 +2627,8 @@ public class BundleWiringImpl implements
                 // Ignore
             }
 
-            String exporter = exports.iterator().next().getRevision().getBundle().toString();
+            String exporter =((BundleCapability) exports.iterator().next())
+                .getRevision().getBundle().toString();
 
             StringBuffer sb = new StringBuffer("*** Class '");
             sb.append(name);

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/Felix.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/Felix.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/Felix.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/Felix.java Fri Oct 21 17:07:06 2011
@@ -30,7 +30,6 @@ import org.apache.felix.framework.cache.
 import org.apache.felix.framework.capabilityset.CapabilitySet;
 import org.apache.felix.framework.capabilityset.SimpleFilter;
 import org.apache.felix.framework.ext.SecurityProvider;
-import org.apache.felix.framework.resolver.ResolveException;
 import org.apache.felix.framework.util.EventDispatcher;
 import org.apache.felix.framework.util.FelixConstants;
 import org.apache.felix.framework.util.ListenerInfo;
@@ -63,6 +62,7 @@ import org.osgi.framework.ServiceListene
 import org.osgi.framework.ServicePermission;
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.ServiceRegistration;
+import org.osgi.framework.resource.Capability;
 import org.osgi.framework.startlevel.FrameworkStartLevel;
 import org.osgi.framework.wiring.BundleCapability;
 import org.osgi.framework.wiring.BundleRevision;
@@ -70,6 +70,7 @@ import org.osgi.framework.wiring.BundleR
 import org.osgi.framework.wiring.BundleWiring;
 import org.osgi.framework.wiring.FrameworkWiring;
 import org.osgi.service.packageadmin.ExportedPackage;
+import org.osgi.service.resolver.ResolutionException;
 
 public class Felix extends BundleImpl implements Framework
 {
@@ -674,12 +675,12 @@ public class Felix extends BundleImpl im
                         Collections.singleton(adapt(BundleRevision.class)),
                         Collections.EMPTY_SET);
                 }
-                catch (ResolveException ex)
+                catch (ResolutionException ex)
                 {
                     // This should never happen.
                     throw new BundleException(
                         "Unresolved constraint in System Bundle:"
-                        + ex.getRequirement());
+                        + ex.getUnresolvedRequirements());
                 }
 
                 // Reload the cached bundles before creating and starting the
@@ -3556,12 +3557,12 @@ public class Felix extends BundleImpl im
             BundleRevision.PACKAGE_NAMESPACE,
             Collections.EMPTY_MAP,
             attrs);
-        Set<BundleCapability> exports = m_resolver.getCandidates(req, false);
+        Set<Capability> exports = m_resolver.findCandidates(req, false);
 
         // We only want resolved capabilities.
-        for (Iterator<BundleCapability> it = exports.iterator(); it.hasNext(); )
+        for (Iterator<Capability> it = exports.iterator(); it.hasNext(); )
         {
-            if (it.next().getRevision().getWiring() == null)
+            if (((BundleCapability) it.next()).getRevision().getWiring() == null)
             {
                 it.remove();
             }
@@ -3571,10 +3572,10 @@ public class Felix extends BundleImpl im
         {
             List pkgs = new ArrayList();
 
-            for (Iterator<BundleCapability> it = exports.iterator(); it.hasNext(); )
+            for (Iterator<Capability> it = exports.iterator(); it.hasNext(); )
             {
                 // Get the bundle associated with the current exporting revision.
-                Bundle bundle = it.next().getRevision().getBundle();
+                Bundle bundle = ((BundleCapability) it.next()).getRevision().getBundle();
 
                 // We need to find the version of the exported package, but this
                 // is tricky since there may be multiple versions of the package
@@ -3785,7 +3786,7 @@ public class Felix extends BundleImpl im
                         }
                     }
                 }
-                catch (ResolveException ex)
+                catch (ResolutionException ex)
                 {
                     result = false;
                 }
@@ -3810,19 +3811,12 @@ public class Felix extends BundleImpl im
         {
             m_resolver.resolve(Collections.singleton(revision), Collections.EMPTY_SET);
         }
-        catch (ResolveException ex)
+        catch (ResolutionException ex)
         {
-            if (ex.getRevision() != null)
-            {
-                Bundle b = ex.getRevision().getBundle();
-                throw new BundleException(
-                    "Unresolved constraint in bundle "
-                    + b + ": " + ex.getMessage(), BundleException.RESOLVE_ERROR);
-            }
-            else
-            {
-                throw new BundleException(ex.getMessage(), BundleException.RESOLVE_ERROR);
-            }
+            Bundle b = revision.getBundle();
+            throw new BundleException(
+                "Unresolved constraint in bundle "
+                + b + ": " + ex.getMessage(), BundleException.RESOLVE_ERROR);
         }
     }
 

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/ServiceRegistry.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/ServiceRegistry.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/ServiceRegistry.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/ServiceRegistry.java Fri Oct 21 17:07:06 2011
@@ -221,7 +221,7 @@ public class ServiceRegistry
         }
         // else just use the specified filter.
 
-        Set<BundleCapability> matches = m_regCapSet.match(filter, false);
+        Set<BundleCapability> matches = m_regCapSet.match(filter);
 
         return new ArrayList(matches);
     }

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/StatefulResolver.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/StatefulResolver.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/StatefulResolver.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/StatefulResolver.java Fri Oct 21 17:07:06 2011
@@ -33,16 +33,15 @@ import java.util.StringTokenizer;
 import java.util.TreeSet;
 import org.apache.felix.framework.capabilityset.CapabilitySet;
 import org.apache.felix.framework.capabilityset.SimpleFilter;
-import org.apache.felix.framework.resolver.CandidateComparator;
-import org.apache.felix.framework.resolver.ResolveException;
-import org.apache.felix.framework.resolver.Resolver;
-import org.apache.felix.framework.resolver.ResolverImpl;
-import org.apache.felix.framework.resolver.ResolverWire;
 import org.apache.felix.framework.util.ShrinkableCollection;
 import org.apache.felix.framework.util.Util;
 import org.apache.felix.framework.util.manifestparser.R4Library;
 import org.apache.felix.framework.wiring.BundleRequirementImpl;
 import org.apache.felix.framework.wiring.BundleWireImpl;
+import org.apache.felix.framework.wiring.CandidateComparator;
+import org.apache.felix.resolver.FelixEnvironment;
+import org.apache.felix.resolver.FelixResolver;
+import org.apache.felix.resolver.impl.ResolverImpl;
 import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleEvent;
 import org.osgi.framework.BundleException;
@@ -53,18 +52,24 @@ import org.osgi.framework.PackagePermiss
 import org.osgi.framework.ServiceReference;
 import org.osgi.framework.hooks.resolver.ResolverHook;
 import org.osgi.framework.hooks.resolver.ResolverHookFactory;
+import org.osgi.framework.resource.Capability;
+import org.osgi.framework.resource.Requirement;
+import org.osgi.framework.resource.Resource;
+import org.osgi.framework.resource.Wire;
+import org.osgi.framework.resource.Wiring;
 import org.osgi.framework.wiring.BundleCapability;
 import org.osgi.framework.wiring.BundleRequirement;
 import org.osgi.framework.wiring.BundleRevision;
 import org.osgi.framework.wiring.BundleWire;
 import org.osgi.framework.wiring.BundleWiring;
+import org.osgi.service.resolver.ResolutionException;
 
 class StatefulResolver
 {
     private final Logger m_logger;
     private final Felix m_felix;
-    private final Resolver m_resolver;
-    private final ResolverStateImpl m_resolverState;
+    private final FelixResolver m_resolver;
+    private final EnvironmentImpl m_resolverState;
     private final List<ResolverHook> m_hooks = new ArrayList<ResolverHook>();
     private boolean m_isResolving = false;
     private Collection<BundleRevision> m_whitelist = null;
@@ -73,8 +78,18 @@ class StatefulResolver
     {
         m_felix = felix;
         m_logger = m_felix.getLogger();
-        m_resolver = new ResolverImpl(m_logger);
-        m_resolverState = new ResolverStateImpl(
+        m_resolver = new ResolverImpl(new org.apache.felix.resolver.Logger() {
+            public void log(int level, String msg)
+            {
+                m_logger.log(level, msg);
+            }
+
+            public void log(int level, String msg, Throwable throwable)
+            {
+                m_logger.log(level, msg, throwable);
+            }
+        });
+        m_resolverState = new EnvironmentImpl(
             (String) m_felix.getConfig().get(Constants.FRAMEWORK_EXECUTIONENVIRONMENT));
     }
 
@@ -88,21 +103,22 @@ class StatefulResolver
         m_resolverState.removeRevision(br);
     }
 
-    Set<BundleCapability> getCandidates(BundleRequirementImpl req, boolean obeyMandatory)
+// TODO: RFC-112 - Callers of this method expect to ignore mandatory attributes.
+    Set<Capability> findCandidates(BundleRequirementImpl req, boolean obeyMandatory)
     {
-        return m_resolverState.getCandidates(req, obeyMandatory);
+        return m_resolverState.findProviders(req);
     }
 
     void resolve(
         Set<BundleRevision> mandatory,
         Set<BundleRevision> optional)
-        throws ResolveException, BundleException
+        throws ResolutionException, BundleException
     {
         // Acquire global lock.
         boolean locked = m_felix.acquireGlobalLock();
         if (!locked)
         {
-            throw new ResolveException(
+            throw new ResolutionException(
                 "Unable to acquire global lock for resolve.", null, null);
         }
 
@@ -115,7 +131,7 @@ class StatefulResolver
         }
         m_isResolving = true;
 
-        Map<BundleRevision, List<ResolverWire>> wireMap = null;
+        Map<Resource, List<Wire>> wireMap = null;
         try
         {
             // Make our own copy of revisions.
@@ -142,7 +158,7 @@ class StatefulResolver
                 }
                 else if (Util.isSingleton(br) && !m_resolverState.isSelectedSingleton(br))
                 {
-                    throw new ResolveException("Singleton conflict.", br, null);
+                    throw new ResolutionException("Singleton conflict: " + br, null, null);
                 }
             }
             for (Iterator<BundleRevision> it = optional.iterator(); it.hasNext(); )
@@ -161,7 +177,7 @@ class StatefulResolver
 
             // Catch any resolve exception to rethrow later because
             // we may need to call end() on resolver hooks.
-            ResolveException rethrow = null;
+            ResolutionException rethrow = null;
             try
             {
                 // Resolve the revision.
@@ -171,7 +187,7 @@ class StatefulResolver
                     optional,
                     m_resolverState.getFragments());
             }
-            catch (ResolveException ex)
+            catch (ResolutionException ex)
             {
                 rethrow = ex;
             }
@@ -204,7 +220,7 @@ class StatefulResolver
     }
 
     BundleRevision resolve(BundleRevision revision, String pkgName)
-        throws ResolveException, BundleException
+        throws ResolutionException, BundleException
     {
         BundleRevision provider = null;
 
@@ -219,8 +235,8 @@ class StatefulResolver
             boolean locked = m_felix.acquireGlobalLock();
             if (!locked)
             {
-                throw new ResolveException(
-                    "Unable to acquire global lock for resolve.", revision, null);
+                throw new ResolutionException(
+                    "Unable to acquire global lock for resolve for " + revision);
             }
 
             // Make sure we are not already resolving, which can be
@@ -232,7 +248,7 @@ class StatefulResolver
             }
             m_isResolving = true;
 
-            Map<BundleRevision, List<ResolverWire>> wireMap = null;
+            Map<Resource, List<Wire>> wireMap = null;
             try
             {
                 // Double check to make sure that someone hasn't beaten us to
@@ -253,14 +269,15 @@ class StatefulResolver
 
                     // Catch any resolve exception to rethrow later because
                     // we may need to call end() on resolver hooks.
-                    ResolveException rethrow = null;
+                    ResolutionException rethrow = null;
                     try
                     {
-                        wireMap = m_resolver.resolve(
-                            m_resolverState, revision, pkgName,
-                            m_resolverState.getFragments());
+// TODO: RFC-112 - Fix dynamic import resolve.
+//                        wireMap = m_resolver.resolve(
+//                            m_resolverState, revision, pkgName,
+//                            m_resolverState.getFragments());
                     }
-                    catch (ResolveException ex)
+                    catch (ResolutionException ex)
                     {
                         rethrow = ex;
                     }
@@ -276,8 +293,8 @@ class StatefulResolver
 
                     if ((wireMap != null) && wireMap.containsKey(revision))
                     {
-                        List<ResolverWire> dynamicWires = wireMap.remove(revision);
-                        ResolverWire dynamicWire = dynamicWires.get(0);
+                        List<Wire> dynamicWires = wireMap.remove(revision);
+                        Wire dynamicWire = dynamicWires.get(0);
 
                         // Mark all revisions as resolved.
                         markResolvedRevisions(wireMap);
@@ -286,10 +303,10 @@ class StatefulResolver
                         if (dynamicWire != null)
                         {
                             BundleWire bw = new BundleWireImpl(
-                                dynamicWire.getRequirer(),
-                                dynamicWire.getRequirement(),
-                                dynamicWire.getProvider(),
-                                dynamicWire.getCapability());
+                                (BundleRevision) dynamicWire.getRequirer(),
+                                (BundleRequirement) dynamicWire.getRequirement(),
+                                (BundleRevision) dynamicWire.getProvider(),
+                                (BundleCapability) dynamicWire.getCapability());
 
                             m_felix.getDependencies().addDependent(bw);
 
@@ -413,7 +430,7 @@ class StatefulResolver
                     optional.retainAll(m_whitelist);
                     if (mandatory.isEmpty() && optional.isEmpty())
                     {
-                        throw new ResolveException(
+                        throw new ResolutionException(
                             "Resolver hook prevented resolution.", null, null);
                     }
                 }
@@ -518,13 +535,13 @@ class StatefulResolver
             BundleRevision.PACKAGE_NAMESPACE,
             Collections.EMPTY_MAP,
             attrs);
-        Set<BundleCapability> candidates = m_resolverState.getCandidates(req, false);
+        Set<Capability> candidates = m_resolverState.findProviders(req);
 
         return !candidates.isEmpty();
     }
 
-    private void markResolvedRevisions(Map<BundleRevision, List<ResolverWire>> wireMap)
-        throws ResolveException
+    private void markResolvedRevisions(Map<Resource, List<Wire>> wireMap)
+        throws ResolutionException
     {
         // DO THIS IN THREE PASSES:
         // 1. Aggregate fragments per host.
@@ -537,26 +554,26 @@ class StatefulResolver
         {
             // First pass: Loop through the wire map to find the host wires
             // for any fragments and map a host to all of its fragments.
-            Map<BundleRevision, List<BundleRevision>> hosts =
-                new HashMap<BundleRevision, List<BundleRevision>>();
-            for (Entry<BundleRevision, List<ResolverWire>> entry : wireMap.entrySet())
+            Map<Resource, List<BundleRevision>> hosts =
+                new HashMap<Resource, List<BundleRevision>>();
+            for (Entry<Resource, List<Wire>> entry : wireMap.entrySet())
             {
-                BundleRevision revision = entry.getKey();
-                List<ResolverWire> wires = entry.getValue();
+                BundleRevision revision = (BundleRevision) entry.getKey();
+                List<Wire> wires = entry.getValue();
 
                 if (Util.isFragment(revision))
                 {
-                    for (Iterator<ResolverWire> itWires = wires.iterator();
+                    for (Iterator<Wire> itWires = wires.iterator();
                         itWires.hasNext(); )
                     {
-                        ResolverWire w = itWires.next();
+                        Wire w = itWires.next();
                         List<BundleRevision> fragments = hosts.get(w.getProvider());
                         if (fragments == null)
                         {
                             fragments = new ArrayList<BundleRevision>();
                             hosts.put(w.getProvider(), fragments);
                         }
-                        fragments.add(w.getRequirer());
+                        fragments.add((BundleRevision) w.getRequirer());
                     }
                 }
             }
@@ -568,12 +585,12 @@ class StatefulResolver
             // that indicates that a revision is resolved and we don't want
             // to mark anything as resolved unless we succussfully create
             // all wirings.
-            Map<BundleRevision, BundleWiringImpl> wirings =
-                new HashMap<BundleRevision, BundleWiringImpl>(wireMap.size());
-            for (Entry<BundleRevision, List<ResolverWire>> entry : wireMap.entrySet())
+            Map<Resource, BundleWiringImpl> wirings =
+                new HashMap<Resource, BundleWiringImpl>(wireMap.size());
+            for (Entry<Resource, List<Wire>> entry : wireMap.entrySet())
             {
-                BundleRevision revision = entry.getKey();
-                List<ResolverWire> resolverWires = entry.getValue();
+                BundleRevision revision = (BundleRevision) entry.getKey();
+                List<Wire> resolverWires = entry.getValue();
 
                 List<BundleWire> bundleWires =
                     new ArrayList<BundleWire>(resolverWires.size());
@@ -595,41 +612,41 @@ class StatefulResolver
                     new HashMap<String, BundleRevision>();
                 Map<String, List<BundleRevision>> requiredPkgs =
                     new HashMap<String, List<BundleRevision>>();
-                for (ResolverWire rw : resolverWires)
+                for (Wire w : resolverWires)
                 {
                     BundleWire bw = new BundleWireImpl(
-                        rw.getRequirer(),
-                        rw.getRequirement(),
-                        rw.getProvider(),
-                        rw.getCapability());
+                        (BundleRevision) w.getRequirer(),
+                        (BundleRequirement) w.getRequirement(),
+                        (BundleRevision) w.getProvider(),
+                        (BundleCapability) w.getCapability());
                     bundleWires.add(bw);
 
                     if (Util.isFragment(revision))
                     {
                         m_felix.getLogger().log(
                             Logger.LOG_DEBUG,
-                            "FRAGMENT WIRE: " + rw.toString());
+                            "FRAGMENT WIRE: " + w.toString());
                     }
                     else
                     {
-                        m_felix.getLogger().log(Logger.LOG_DEBUG, "WIRE: " + rw.toString());
+                        m_felix.getLogger().log(Logger.LOG_DEBUG, "WIRE: " + w.toString());
 
-                        if (rw.getCapability().getNamespace()
+                        if (w.getCapability().getNamespace()
                             .equals(BundleRevision.PACKAGE_NAMESPACE))
                         {
                             importedPkgs.put(
-                                (String) rw.getCapability().getAttributes()
+                                (String) w.getCapability().getAttributes()
                                     .get(BundleRevision.PACKAGE_NAMESPACE),
-                                rw.getProvider());
+                                (BundleRevision) w.getProvider());
                         }
-                        else if (rw.getCapability().getNamespace()
+                        else if (w.getCapability().getNamespace()
                             .equals(BundleRevision.BUNDLE_NAMESPACE))
                         {
                             Set<String> pkgs = calculateExportedAndReexportedPackages(
-                                    rw.getProvider(),
+                                    w.getProvider(),
                                     wireMap,
                                     new HashSet<String>(),
-                                    new HashSet<BundleRevision>());
+                                    new HashSet<Resource>());
                             for (String pkg : pkgs)
                             {
                                 List<BundleRevision> revs = requiredPkgs.get(pkg);
@@ -638,7 +655,7 @@ class StatefulResolver
                                     revs = new ArrayList<BundleRevision>();
                                     requiredPkgs.put(pkg, revs);
                                 }
-                                revs.add(rw.getProvider());
+                                revs.add((BundleRevision) w.getProvider());
                             }
                         }
                     }
@@ -663,7 +680,7 @@ class StatefulResolver
                 {
                     // This is a fatal error, so undo everything and
                     // throw an exception.
-                    for (Entry<BundleRevision, BundleWiringImpl> wiringEntry
+                    for (Entry<Resource, BundleWiringImpl> wiringEntry
                         : wirings.entrySet())
                     {
                         // Dispose of wiring.
@@ -683,9 +700,9 @@ class StatefulResolver
                         }
                     }
 
-                    ResolveException re = new ResolveException(
+                    ResolutionException re = new ResolutionException(
                         "Unable to resolve " + revision,
-                        revision, null);
+                        null, null);
                     re.initCause(ex);
                     m_felix.getLogger().log(
                         Logger.LOG_ERROR,
@@ -696,7 +713,7 @@ class StatefulResolver
 
             // Third pass: Loop through the wire map to mark revision as resolved
             // and update the resolver state.
-            for (Entry<BundleRevision, BundleWiringImpl> entry : wirings.entrySet())
+            for (Entry<Resource, BundleWiringImpl> entry : wirings.entrySet())
             {
                 BundleRevisionImpl revision = (BundleRevisionImpl) entry.getKey();
 
@@ -763,17 +780,17 @@ class StatefulResolver
         }
     }
 
-    private void fireResolvedEvents(Map<BundleRevision, List<ResolverWire>> wireMap)
+    private void fireResolvedEvents(Map<Resource, List<Wire>> wireMap)
     {
         if (wireMap != null)
         {
-            Iterator<Entry<BundleRevision, List<ResolverWire>>> iter =
+            Iterator<Entry<Resource, List<Wire>>> iter =
                 wireMap.entrySet().iterator();
             // Iterate over the map to fire necessary RESOLVED events.
             while (iter.hasNext())
             {
-                Entry<BundleRevision, List<ResolverWire>> entry = iter.next();
-                BundleRevision revision = entry.getKey();
+                Entry<Resource, List<Wire>> entry = iter.next();
+                BundleRevision revision = (BundleRevision) entry.getKey();
 
                 // Fire RESOLVED events for all fragments.
                 List<BundleRevision> fragments =
@@ -789,17 +806,17 @@ class StatefulResolver
     }
 
     private static Set<String> calculateExportedAndReexportedPackages(
-        BundleRevision br,
-        Map<BundleRevision, List<ResolverWire>> wireMap,
+        Resource resource,
+        Map<Resource, List<Wire>> wireMap,
         Set<String> pkgs,
-        Set<BundleRevision> cycles)
+        Set<Resource> cycles)
     {
-        if (!cycles.contains(br))
+        if (!cycles.contains(resource))
         {
-            cycles.add(br);
+            cycles.add(resource);
 
             // Add all exported packages.
-            for (BundleCapability cap : br.getDeclaredCapabilities(null))
+            for (Capability cap : resource.getCapabilities(null))
             {
                 if (cap.getNamespace().equals(BundleRevision.PACKAGE_NAMESPACE))
                 {
@@ -810,19 +827,20 @@ class StatefulResolver
 
             // Now check to see if any required bundles are required with reexport
             // visibility, since we need to include those packages too.
-            if (br.getWiring() == null)
+            BundleWiring wiring = ((BundleRevision) resource).getWiring();
+            if (wiring == null)
             {
-                for (ResolverWire rw : wireMap.get(br))
+                for (Wire w : wireMap.get(resource))
                 {
-                    if (rw.getCapability().getNamespace().equals(
+                    if (w.getCapability().getNamespace().equals(
                         BundleRevision.BUNDLE_NAMESPACE))
                     {
-                        String dir = rw.getRequirement()
+                        String dir = w.getRequirement()
                             .getDirectives().get(Constants.VISIBILITY_DIRECTIVE);
                         if ((dir != null) && (dir.equals(Constants.VISIBILITY_REEXPORT)))
                         {
                             calculateExportedAndReexportedPackages(
-                                rw.getProvider(),
+                                w.getProvider(),
                                 wireMap,
                                 pkgs,
                                 cycles);
@@ -832,7 +850,7 @@ class StatefulResolver
             }
             else
             {
-                for (BundleWire bw : br.getWiring().getRequiredWires(null))
+                for (BundleWire bw : wiring.getRequiredWires(null))
                 {
                     if (bw.getCapability().getNamespace().equals(
                         BundleRevision.BUNDLE_NAMESPACE))
@@ -855,7 +873,7 @@ class StatefulResolver
         return pkgs;
     }
 
-    class ResolverStateImpl implements Resolver.ResolverState
+    class EnvironmentImpl implements FelixEnvironment
     {
         // Set of all revisions.
         private final Set<BundleRevision> m_revisions;
@@ -882,7 +900,7 @@ class StatefulResolver
 //        }
 //    }
 
-        ResolverStateImpl(String fwkExecEnvStr)
+        EnvironmentImpl(String fwkExecEnvStr)
         {
             m_revisions = new HashSet<BundleRevision>();
             m_fragments = new HashSet<BundleRevision>();
@@ -1248,19 +1266,17 @@ class StatefulResolver
         }
 
         //
-        // ResolverState methods.
+        // Environment methods.
         //
 
-        public boolean isEffective(BundleRequirement req)
+        public boolean isEffective(Requirement req)
         {
             String effective = req.getDirectives().get(Constants.EFFECTIVE_DIRECTIVE);
             return ((effective == null) || effective.equals(Constants.EFFECTIVE_RESOLVE));
         }
 
-        public synchronized SortedSet<BundleCapability> getCandidates(
-            BundleRequirement req, boolean obeyMandatory)
+        public synchronized SortedSet<Capability> findProviders(Requirement req)
         {
-            BundleRevisionImpl reqRevision = (BundleRevisionImpl) req.getRevision();
             SortedSet<BundleCapability> result =
                 new TreeSet<BundleCapability>(new CandidateComparator());
 
@@ -1289,7 +1305,7 @@ class StatefulResolver
                 }
 
                 // Find the matching candidates.
-                Set<BundleCapability> matches = capSet.match(sf, obeyMandatory);
+                Set<BundleCapability> matches = capSet.match(sf);
                 // Filter matching candidates.
                 for (BundleCapability cap : matches)
                 {
@@ -1335,7 +1351,7 @@ class StatefulResolver
                     try
                     {
                         Felix.m_secureAction
-                            .invokeResolverHookMatches(hook, req, shrinkable);
+                            .invokeResolverHookMatches(hook, (BundleRequirement) req, shrinkable);
                     }
                     catch (Throwable th)
                     {
@@ -1344,14 +1360,14 @@ class StatefulResolver
                 }
             }
 
-            return result;
+            return asCapabilitySortedSet(result);
         }
 
-        private boolean filteredBySecurity(BundleRequirement req, BundleCapability cap)
+        private boolean filteredBySecurity(Requirement req, BundleCapability cap)
         {
             if (System.getSecurityManager() != null)
             {
-                BundleRevisionImpl reqRevision = (BundleRevisionImpl) req.getRevision();
+                BundleRevisionImpl reqRevision = (BundleRevisionImpl) req.getResource();
 
                 if (req.getNamespace().equals(BundleRevision.PACKAGE_NAMESPACE))
                 {
@@ -1410,7 +1426,22 @@ class StatefulResolver
             return false;
         }
 
-        public void checkExecutionEnvironment(BundleRevision revision) throws ResolveException
+// TODO: RFC-112 - Optimize this.
+        public Map<Resource, Wiring> getWirings()
+        {
+            Map<Resource, Wiring> wirings = new HashMap<Resource, Wiring>();
+
+            for (BundleRevision revision : m_revisions)
+            {
+                if (revision.getWiring() != null)
+                {
+                    wirings.put(revision, revision.getWiring());
+                }
+            }
+            return wirings;
+        }
+
+        public void checkExecutionEnvironment(Resource revision) throws ResolutionException
         {
             String bundleExecEnvStr = (String)
                 ((BundleRevisionImpl) revision).getHeaders().get(
@@ -1437,15 +1468,15 @@ class StatefulResolver
                     }
                     if (!found)
                     {
-                        throw new ResolveException(
+                        throw new ResolutionException(
                             "Execution environment not supported: "
-                            + bundleExecEnvStr, revision, null);
+                            + bundleExecEnvStr + " for " + revision, null, null);
                     }
                 }
             }
         }
 
-        public void checkNativeLibraries(BundleRevision revision) throws ResolveException
+        public void checkNativeLibraries(Resource revision) throws ResolutionException
         {
             // Next, try to resolve any native code, since the revision is
             // not resolvable if its native code cannot be loaded.
@@ -1475,7 +1506,7 @@ class StatefulResolver
                 }
                 if (msg != null)
                 {
-                    throw new ResolveException(msg, revision, null);
+                    throw new ResolutionException(msg + " for " + revision, null, null);
                 }
             }
         }
@@ -1485,6 +1516,11 @@ class StatefulResolver
     // Utility methods.
     //
 
+    private static SortedSet<Capability> asCapabilitySortedSet(SortedSet<? extends Capability> ss)
+    {
+        return (SortedSet<Capability>) ss;
+    }
+
     /**
      * Updates the framework wide execution environment string and a cached Set of
      * execution environment tokens from the comma delimited list specified by the

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/capabilityset/CapabilitySet.java Fri Oct 21 17:07:06 2011
@@ -33,6 +33,7 @@ import java.util.TreeMap;
 import org.apache.felix.framework.util.SecureAction;
 import org.apache.felix.framework.util.StringComparator;
 import org.apache.felix.framework.wiring.BundleCapabilityImpl;
+import org.osgi.framework.resource.Capability;
 import org.osgi.framework.wiring.BundleCapability;
 
 public class CapabilitySet
@@ -175,12 +176,10 @@ public void dump()
         }
     }
 
-    public Set<BundleCapability> match(SimpleFilter sf, boolean obeyMandatory)
+    public Set<BundleCapability> match(SimpleFilter sf)
     {
         Set<BundleCapability> matches = match(m_capSet, sf);
-        return (obeyMandatory)
-            ? matchMandatory(matches, sf)
-            : matches;
+        return matchMandatory(matches, sf);
     }
 
     private Set<BundleCapability> match(Set<BundleCapability> caps, SimpleFilter sf)
@@ -257,12 +256,12 @@ public void dump()
         return matches;
     }
 
-    public static boolean matches(BundleCapability cap, SimpleFilter sf)
+    public static boolean matches(Capability cap, SimpleFilter sf)
     {
         return matchesInternal(cap, sf) && matchMandatory(cap, sf);
     }
 
-    private static boolean matchesInternal(BundleCapability cap, SimpleFilter sf)
+    private static boolean matchesInternal(Capability cap, SimpleFilter sf)
     {
         boolean matched = true;
 
@@ -330,7 +329,10 @@ public void dump()
         return caps;
     }
 
-    private static boolean matchMandatory(BundleCapability cap, SimpleFilter sf)
+// TODO: RFC-112 - Since this is happening all the time, maybe we should look
+//       into optimizing it since more caps won't have mandatory attrs; it
+//       would be better to just check this once and set a flag in
+    private static boolean matchMandatory(Capability cap, SimpleFilter sf)
     {
         Map<String, Object> attrs = cap.getAttributes();
         for (Entry<String, Object> entry : attrs.entrySet())

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/util/Util.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/util/Util.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/util/Util.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/util/Util.java Fri Oct 21 17:07:06 2011
@@ -626,15 +626,8 @@ public class Util
             // Find the bundle capability and check its directives.
             if (cap.getNamespace().equals(BundleRevision.BUNDLE_NAMESPACE))
             {
-                for (Entry<String, String> entry : cap.getDirectives().entrySet())
-                {
-                    if (entry.getKey().equalsIgnoreCase(Constants.SINGLETON_DIRECTIVE))
-                    {
-                        return Boolean.valueOf((String) entry.getValue());
-                    }
-                }
-                // Can only have one bundle capability, so break.
-                break;
+                String dir = cap.getDirectives().get(Constants.SINGLETON_DIRECTIVE);
+                return (dir != null) && Boolean.valueOf(dir);
             }
         }
         return false;

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/util/manifestparser/ManifestParser.java Fri Oct 21 17:07:06 2011
@@ -31,6 +31,7 @@ import org.apache.felix.framework.wiring
 import org.osgi.framework.BundleException;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
+import org.osgi.framework.resource.ResourceConstants;
 import org.osgi.framework.wiring.BundleCapability;
 import org.osgi.framework.wiring.BundleRequirement;
 import org.osgi.framework.wiring.BundleRevision;
@@ -102,9 +103,37 @@ public class ManifestParser
             m_bundleSymbolicName = (String)
                 bundleCap.getAttributes().get(BundleRevision.BUNDLE_NAMESPACE);
 
+            // All bundles get an identity capability, so synthesize one.
+            Map<String, String> idDirs = Collections.EMPTY_MAP;
+            String singleton = bundleCap.getDirectives().get(Constants.SINGLETON_DIRECTIVE);
+            if ((singleton != null) && Boolean.valueOf(singleton))
+            {
+                Collections.singletonMap(
+                    ResourceConstants.IDENTITY_SINGLETON_DIRECTIVE,
+                    singleton);
+            }
+            Map<String, Object> idAttrs = new HashMap<String, Object>();
+            idAttrs.put(
+                ResourceConstants.IDENTITY_NAMESPACE,
+                m_bundleSymbolicName);
+            idAttrs.put(
+                ResourceConstants.IDENTITY_VERSION_ATTRIBUTE,
+                bundleCap.getAttributes().get(Constants.BUNDLE_VERSION_ATTRIBUTE));
+            idAttrs.put(
+                ResourceConstants.IDENTITY_TYPE_ATTRIBUTE,
+                (headerMap.containsKey(Constants.FRAGMENT_ATTACHMENT_ALWAYS)
+                    ? ResourceConstants.IDENTITY_TYPE_FRAGMENT
+                    : ResourceConstants.IDENTITY_TYPE_BUNDLE));
+            capList.add(
+                new BundleCapabilityImpl(
+                    owner,
+                    ResourceConstants.IDENTITY_NAMESPACE,
+                    idDirs,
+                    idAttrs));
+
             // Add a bundle capability and a host capability to all
             // non-fragment bundles. A host capability is the same
-            // as a require capability, but with a different capability
+            // as a bundle capability, but with a different capability
             // namespace. Bundle capabilities resolve required-bundle
             // dependencies, while host capabilities resolve fragment-host
             // dependencies.
@@ -1545,7 +1574,7 @@ public class ManifestParser
                     "A header cannot be an empty string.");
             }
             List<ParsedHeaderClause> clauses = parseStandardHeader(header);
-            
+
             for (ParsedHeaderClause clause : clauses)
             {
                 System.out.println("PATHS " + clause.m_paths);
@@ -1553,33 +1582,33 @@ public class ManifestParser
                 System.out.println("    ATTRS " + clause.m_attrs);
                 System.out.println("    TYPES " + clause.m_types);
             }
-            
+
         }
     }
-    
+
     private static final char EOF = (char) -1;
-    
-    private static char charAt(int pos, String headers, int length) 
+
+    private static char charAt(int pos, String headers, int length)
     {
-        if (pos >= length) 
+        if (pos >= length)
         {
             return EOF;
         }
         return headers.charAt(pos);
     }
-    
+
     private static final int CLAUSE_START = 0;
     private static final int PARAMETER_START = 1;
     private static final int KEY = 2;
     private static final int DIRECTIVE_OR_TYPEDATTRIBUTE = 4;
     private static final int ARGUMENT = 8;
     private static final int VALUE = 16;
-    
+
     @SuppressWarnings({ "unchecked", "rawtypes" })
-    private static List<ParsedHeaderClause> parseStandardHeader(String header) 
+    private static List<ParsedHeaderClause> parseStandardHeader(String header)
     {
         List<ParsedHeaderClause> clauses = new ArrayList<ParsedHeaderClause>();
-        if (header == null) 
+        if (header == null)
         {
             return clauses;
         }
@@ -1592,12 +1621,12 @@ public class ManifestParser
         int length = header.length();
         boolean quoted = false;
         boolean escaped = false;
-        
+
         char currentChar = EOF;
-        do  
+        do
         {
             currentChar = charAt(currentPosition, header, length);
-            switch (state) 
+            switch (state)
             {
                 case CLAUSE_START:
                     clause = new ParsedHeaderClause(
@@ -1611,10 +1640,10 @@ public class ManifestParser
                     startPosition = currentPosition;
                     state = KEY;
                 case KEY:
-                    switch (currentChar) 
+                    switch (currentChar)
                     {
                         case ':':
-                        case '=': 
+                        case '=':
                             key = header.substring(startPosition, currentPosition).trim();
                             startPosition = currentPosition + 1;
                             targetMap = clause.m_attrs;
@@ -1632,14 +1661,14 @@ public class ManifestParser
                     currentPosition++;
                     break;
                 case DIRECTIVE_OR_TYPEDATTRIBUTE:
-                    switch(currentChar) 
+                    switch(currentChar)
                     {
                         case '=':
-                            if (startPosition != currentPosition) 
+                            if (startPosition != currentPosition)
                             {
                                 clause.m_types.put(key, header.substring(startPosition, currentPosition).trim());
                             }
-                            else 
+                            else
                             {
                                 targetMap = clause.m_dirs;
                             }
@@ -1652,12 +1681,12 @@ public class ManifestParser
                     currentPosition++;
                     break;
                 case ARGUMENT:
-                    if (currentChar == '\"') 
+                    if (currentChar == '\"')
                     {
                         quoted = true;
                         currentPosition++;
                     }
-                    else 
+                    else
                     {
                         quoted = false;
                     }
@@ -1669,35 +1698,35 @@ public class ManifestParser
                     }
                     break;
                 case VALUE:
-                    if (currentChar == '\\' ) 
+                    if (currentChar == '\\' )
                     {
-                        if (escaped) 
+                        if (escaped)
                         {
                             escaped = false;
                         }
-                        else 
+                        else
                         {
                             escaped = true;
                         }
                     }
-                    if (quoted && !escaped && currentChar == '\"') 
+                    if (quoted && !escaped && currentChar == '\"')
                     {
                         quoted = false;
-                    } 
+                    }
                     else if (!quoted)
                     {
                         String value = null;
-                        switch(currentChar) 
+                        switch(currentChar)
                         {
                             case EOF:
                             case ';':
                             case ',':
                                 value = header.substring(startPosition, currentPosition).trim();
-                                if (value.startsWith("\"") && value.endsWith("\"")) 
+                                if (value.startsWith("\"") && value.endsWith("\""))
                                 {
                                     value = value.substring(1, value.length() - 1);
                                 }
-                                if (targetMap.put(key, value) != null) 
+                                if (targetMap.put(key, value) != null)
                                 {
                                     throw new IllegalArgumentException(
                                             "Duplicate '" + key + "' in: " + header);
@@ -1712,10 +1741,10 @@ public class ManifestParser
                     break;
                 default:
                     break;
-            }   
+            }
         } while ( currentChar != EOF);
-        
-        if (state > PARAMETER_START) 
+
+        if (state > PARAMETER_START)
         {
             throw new IllegalArgumentException("Unable to parse header: " + header);
         }

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/wiring/BundleCapabilityImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/wiring/BundleCapabilityImpl.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/wiring/BundleCapabilityImpl.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/wiring/BundleCapabilityImpl.java Fri Oct 21 17:07:06 2011
@@ -29,6 +29,7 @@ import org.apache.felix.framework.capabi
 import org.apache.felix.framework.util.Util;
 import org.apache.felix.framework.util.manifestparser.ManifestParser;
 import org.osgi.framework.Constants;
+import org.osgi.framework.resource.Resource;
 import org.osgi.framework.wiring.BundleCapability;
 import org.osgi.framework.wiring.BundleRevision;
 
@@ -125,6 +126,11 @@ public class BundleCapabilityImpl implem
         m_mandatory = mandatory;
     }
 
+    public Resource getResource()
+    {
+        return m_revision;
+    }
+
     public BundleRevision getRevision()
     {
         return m_revision;

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/wiring/BundleRequirementImpl.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/wiring/BundleRequirementImpl.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/wiring/BundleRequirementImpl.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/wiring/BundleRequirementImpl.java Fri Oct 21 17:07:06 2011
@@ -18,15 +18,13 @@
  */
 package org.apache.felix.framework.wiring;
 
-import java.util.ArrayList;
 import java.util.Collections;
-import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import org.apache.felix.framework.capabilityset.CapabilitySet;
 import org.apache.felix.framework.capabilityset.SimpleFilter;
-import org.apache.felix.framework.util.VersionRange;
 import org.osgi.framework.Constants;
+import org.osgi.framework.resource.Capability;
+import org.osgi.framework.resource.Resource;
 import org.osgi.framework.wiring.BundleCapability;
 import org.osgi.framework.wiring.BundleRequirement;
 import org.osgi.framework.wiring.BundleRevision;
@@ -82,14 +80,24 @@ public class BundleRequirementImpl imple
         return m_attrs;
     }
 
+    public Resource getResource()
+    {
+        return m_revision;
+    }
+
     public BundleRevision getRevision()
     {
         return m_revision;
     }
 
+    public boolean matches(Capability cap)
+    {
+        return CapabilitySet.matches(cap, getFilter());
+    }
+
     public boolean matches(BundleCapability cap)
     {
-        return CapabilitySet.matches((BundleCapabilityImpl) cap, getFilter());
+        return CapabilitySet.matches(cap, getFilter());
     }
 
     public boolean isOptional()
@@ -102,6 +110,7 @@ public class BundleRequirementImpl imple
         return m_filter;
     }
 
+    @Override
     public String toString()
     {
         return "[" + m_revision + "] " + m_namespace + "; " + getFilter().toString();

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/wiring/CandidateComparator.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/wiring/CandidateComparator.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/wiring/CandidateComparator.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/apache/felix/framework/wiring/CandidateComparator.java Fri Oct 21 17:07:06 2011
@@ -21,24 +21,29 @@ package org.apache.felix.framework.wirin
 import java.util.Comparator;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
+import org.osgi.framework.resource.Capability;
 import org.osgi.framework.wiring.BundleCapability;
 import org.osgi.framework.wiring.BundleRevision;
+import org.osgi.framework.wiring.BundleWiring;
 
-public class CandidateComparator implements Comparator<BundleCapability>
+public class CandidateComparator implements Comparator<Capability>
 {
-    public int compare(BundleCapability cap1, BundleCapability cap2)
+    public int compare(Capability cap1, Capability cap2)
     {
+        BundleWiring wiring1 = (cap1 instanceof BundleCapability)
+            ? ((BundleCapability) cap1).getRevision().getWiring() : null;
+        BundleWiring wiring2 = (cap2 instanceof BundleCapability)
+            ? ((BundleCapability) cap2).getRevision().getWiring() : null;
+
         // First check resolved state, since resolved capabilities have priority
         // over unresolved ones. Compare in reverse order since we want to sort
         // in descending order.
         int c = 0;
-        if ((cap1.getRevision().getWiring() != null)
-            && (cap2.getRevision().getWiring() == null))
+        if ((wiring1 != null) && (wiring2 == null))
         {
             c = -1;
         }
-        else if ((cap1.getRevision().getWiring() == null)
-            && (cap2.getRevision().getWiring() != null))
+        else if ((wiring1 == null) && (wiring2 != null))
         {
             c = 1;
         }
@@ -83,13 +88,16 @@ public class CandidateComparator impleme
         // Finally, compare bundle identity.
         if (c == 0)
         {
-            if (cap1.getRevision().getBundle().getBundleId() <
-                cap2.getRevision().getBundle().getBundleId())
+            long id1 = (cap1 instanceof BundleCapability)
+                ? ((BundleCapability) cap1).getRevision().getBundle().getBundleId() : -1;
+            long id2 = (cap2 instanceof BundleCapability)
+                ? ((BundleCapability) cap2).getRevision().getBundle().getBundleId() : -1;
+
+            if (id1 < id2)
             {
                 c = -1;
             }
-            else if (cap1.getRevision().getBundle().getBundleId() >
-                cap2.getRevision().getBundle().getBundleId())
+            else if (id1 > id2)
             {
                 c = 1;
             }

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleCapability.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleCapability.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleCapability.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleCapability.java Fri Oct 21 17:07:06 2011
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) OSGi Alliance (2010, 2011). All Rights Reserved.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -17,26 +17,27 @@
 package org.osgi.framework.wiring;
 
 import java.util.Map;
+import org.osgi.framework.resource.Capability;
 
 /**
  * A capability that has been declared from a {@link BundleRevision bundle
  * revision}.
- * 
+ *
  * @ThreadSafe
  * @noimplement
  * @version $Id: 0fde13c3228af1aa97872b37ccf0aa6e23123b11 $
  */
-public interface BundleCapability {
+public interface BundleCapability extends Capability {
 	/**
 	 * Returns the name space of this capability.
-	 * 
+	 *
 	 * @return The name space of this capability.
 	 */
 	String getNamespace();
 
 	/**
 	 * Returns the directives of this capability.
-	 * 
+	 *
 	 * @return An unmodifiable map of directive names to directive values for
 	 *         this capability, or an empty map if this capability has no
 	 *         directives.
@@ -45,7 +46,7 @@ public interface BundleCapability {
 
 	/**
 	 * Returns the attributes of this capability.
-	 * 
+	 *
 	 * @return An unmodifiable map of attribute names to attribute values for
 	 *         this capability, or an empty map if this capability has no
 	 *         attributes.
@@ -54,7 +55,7 @@ public interface BundleCapability {
 
 	/**
 	 * Returns the bundle revision declaring this capability.
-	 * 
+	 *
 	 * @return The bundle revision declaring this capability.
 	 */
 	BundleRevision getRevision();

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleRequirement.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleRequirement.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleRequirement.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleRequirement.java Fri Oct 21 17:07:06 2011
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) OSGi Alliance (2010, 2011). All Rights Reserved.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -17,26 +17,27 @@
 package org.osgi.framework.wiring;
 
 import java.util.Map;
+import org.osgi.framework.resource.Requirement;
 
 /**
  * A requirement that has been declared from a {@link BundleRevision bundle
  * revision}.
- * 
+ *
  * @ThreadSafe
  * @noimplement
  * @version $Id: 659132c1fac7526240df377ead0e1bc8d4af2e77 $
  */
-public interface BundleRequirement {
+public interface BundleRequirement extends Requirement {
 	/**
 	 * Returns the name space of this requirement.
-	 * 
+	 *
 	 * @return The name space of this requirement.
 	 */
 	String getNamespace();
 
 	/**
 	 * Returns the directives of this requirement.
-	 * 
+	 *
 	 * @return An unmodifiable map of directive names to directive values for
 	 *         this requirement, or an empty map if this requirement has no
 	 *         directives.
@@ -45,7 +46,7 @@ public interface BundleRequirement {
 
 	/**
 	 * Returns the attributes of this requirement.
-	 * 
+	 *
 	 * @return An unmodifiable map of attribute names to attribute values for
 	 *         this requirement, or an empty map if this requirement has no
 	 *         attributes.
@@ -54,14 +55,14 @@ public interface BundleRequirement {
 
 	/**
 	 * Returns the bundle revision declaring this requirement.
-	 * 
+	 *
 	 * @return The bundle revision declaring this requirement.
 	 */
 	BundleRevision getRevision();
 
 	/**
 	 * Returns whether the specified capability matches this requirement.
-	 * 
+	 *
 	 * @param capability The capability to match to this requirement.
 	 * @return {@code true} if the specified capability has the same
 	 *         {@link #getNamespace() name space} as this requirement and the

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleRevision.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleRevision.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleRevision.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleRevision.java Fri Oct 21 17:07:06 2011
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) OSGi Alliance (2010, 2011). All Rights Reserved.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -22,13 +22,14 @@ import org.osgi.framework.Bundle;
 import org.osgi.framework.BundleReference;
 import org.osgi.framework.Constants;
 import org.osgi.framework.Version;
+import org.osgi.framework.resource.Resource;
 
 /**
  * Bundle Revision. When a bundle is installed and each time a bundle is
  * updated, a new bundle revision of the bundle is created. Since a bundle
  * update can change the entries in a bundle, different bundle wirings for the
  * same bundle can be associated with different bundle revisions.
- * 
+ *
  * <p>
  * For a bundle that has not been uninstalled, the most recent bundle revision
  * is defined to be the current bundle revision. A bundle in the UNINSTALLED
@@ -36,7 +37,7 @@ import org.osgi.framework.Version;
  * bundle can be obtained by calling {@link Bundle#adapt(Class) bundle.adapt}
  * (BundleRevision.class). Since a bundle in the UNINSTALLED state does not have
  * a current revision, adapting such a bundle returns {@code null}.
- * 
+ *
  * <p>
  * The framework defines name spaces for {@link #PACKAGE_NAMESPACE package},
  * {@link #BUNDLE_NAMESPACE bundle} and {@link #HOST_NAMESPACE host}
@@ -44,15 +45,15 @@ import org.osgi.framework.Version;
  * wiring information by the framework. They must not be used in
  * {@link Constants#PROVIDE_CAPABILITY Provide-Capability} and
  * {@link Constants#REQUIRE_CAPABILITY Require-Capability} manifest headers.
- * 
+ *
  * @ThreadSafe
  * @noimplement
  * @version $Id: 139b3046ebd46c48b03dda8d36f2f9d79e2e616d $
  */
-public interface BundleRevision extends BundleReference {
+public interface BundleRevision extends BundleReference, Resource {
 	/**
 	 * Returns the symbolic name for this bundle revision.
-	 * 
+	 *
 	 * @return The symbolic name for this bundle revision.
 	 * @see Bundle#getSymbolicName()
 	 */
@@ -60,7 +61,7 @@ public interface BundleRevision extends 
 
 	/**
 	 * Returns the version for this bundle revision.
-	 * 
+	 *
 	 * @return The version for this bundle revision, or
 	 *         {@link Version#emptyVersion} if this bundle revision has no
 	 *         version information.
@@ -70,7 +71,7 @@ public interface BundleRevision extends 
 
 	/**
 	 * Returns the capabilities declared by this bundle revision.
-	 * 
+	 *
 	 * @param namespace The name space of the declared capabilities to return or
 	 *        {@code null} to return the declared capabilities from all name
 	 *        spaces.
@@ -84,7 +85,7 @@ public interface BundleRevision extends 
 
 	/**
 	 * Returns the requirements declared by this bundle revision.
-	 * 
+	 *
 	 * @param namespace The name space of the declared requirements to return or
 	 *        {@code null} to return the declared requirements from all name
 	 *        spaces.
@@ -98,7 +99,7 @@ public interface BundleRevision extends 
 
 	/**
 	 * Name space for package capabilities and requirements.
-	 * 
+	 *
 	 * <p>
 	 * The name of the package is stored in the capability attribute of the same
 	 * name as this name space (osgi.wiring.package). The other
@@ -116,14 +117,14 @@ public interface BundleRevision extends 
 	 * bundle-version} capability attribute must contain the
 	 * {@link BundleRevision#getVersion() version} of the provider if one is
 	 * specified or {@link Version#emptyVersion} if not specified.
-	 * 
+	 *
 	 * <p>
 	 * The package capabilities provided by the system bundle, that is the
 	 * bundle with id zero, must include the package specified by the
 	 * {@link Constants#FRAMEWORK_SYSTEMPACKAGES} and
 	 * {@link Constants#FRAMEWORK_SYSTEMPACKAGES_EXTRA} framework properties as
 	 * well as any other package exported by the framework implementation.
-	 * 
+	 *
 	 * <p>
 	 * A bundle revision {@link BundleRevision#getDeclaredCapabilities(String)
 	 * declares} zero or more package capabilities (this is, exported packages)
@@ -141,7 +142,7 @@ public interface BundleRevision extends 
 
 	/**
 	 * Name space for bundle capabilities and requirements.
-	 * 
+	 *
 	 * <p>
 	 * The bundle symbolic name of the bundle is stored in the capability
 	 * attribute of the same name as this name space (osgi.wiring.bundle).
@@ -154,14 +155,14 @@ public interface BundleRevision extends 
 	 * attribute must contain the {@link Version} of the bundle from the
 	 * {@link Constants#BUNDLE_VERSION Bundle-Version} manifest header if one is
 	 * specified or {@link Version#emptyVersion} if not specified.
-	 * 
+	 *
 	 * <p>
 	 * A non-fragment revision
 	 * {@link BundleRevision#getDeclaredCapabilities(String) declares} exactly
 	 * one<sup>&#8224;</sup> bundle capability (that is, the bundle can be
 	 * required by another bundle). A fragment revision must not declare a
 	 * bundle capability.
-	 * 
+	 *
 	 * <p>
 	 * A bundle wiring for a non-fragment revision
 	 * {@link BundleWiring#getCapabilities(String) provides} exactly
@@ -169,7 +170,7 @@ public interface BundleRevision extends 
 	 * required by another bundle) and
 	 * {@link BundleWiring#getRequiredWires(String) requires} zero or more
 	 * bundle capabilities (that is, requires other bundles).
-	 * 
+	 *
 	 * <p>
 	 * &#8224; A bundle with no bundle symbolic name (that is, a bundle with
 	 * {@link Constants#BUNDLE_MANIFESTVERSION Bundle-ManifestVersion}
@@ -179,7 +180,7 @@ public interface BundleRevision extends 
 
 	/**
 	 * Name space for host capabilities and requirements.
-	 * 
+	 *
 	 * <p>
 	 * The bundle symbolic name of the bundle is stored in the capability
 	 * attribute of the same name as this name space (osgi.wiring.host).
@@ -192,7 +193,7 @@ public interface BundleRevision extends 
 	 * attribute must contain the {@link Version} of the bundle from the
 	 * {@link Constants#BUNDLE_VERSION Bundle-Version} manifest header if one is
 	 * specified or {@link Version#emptyVersion} if not specified.
-	 * 
+	 *
 	 * <p>
 	 * A non-fragment revision
 	 * {@link BundleRevision#getDeclaredCapabilities(String) declares} zero or
@@ -201,7 +202,7 @@ public interface BundleRevision extends 
 	 * attached}. A fragment revision must
 	 * {@link BundleRevision#getDeclaredRequirements(String) declare} exactly
 	 * one host requirement.
-	 * 
+	 *
 	 * <p>
 	 * A bundle wiring for a non-fragment revision
 	 * {@link BundleWiring#getCapabilities(String) provides} zero or
@@ -210,7 +211,7 @@ public interface BundleRevision extends 
 	 * attached}. A bundle wiring for a fragment revision
 	 * {@link BundleWiring#getRequiredWires(String) requires} a host capability
 	 * for each host to which it is attached.
-	 * 
+	 *
 	 * <p>
 	 * &#8224; A bundle with no bundle symbolic name (that is, a bundle with
 	 * {@link Constants#BUNDLE_MANIFESTVERSION Bundle-ManifestVersion}
@@ -224,14 +225,14 @@ public interface BundleRevision extends 
 	 * <ul>
 	 * <li>{@link #TYPE_FRAGMENT}
 	 * </ul>
-	 * 
+	 *
 	 * A bundle revision may be more than one type at a time. A type code is
 	 * used to identify the bundle revision type for future extendability.
-	 * 
+	 *
 	 * <p>
 	 * If this bundle revision is not one or more of the defined types then 0 is
 	 * returned.
-	 * 
+	 *
 	 * @return The special types of this bundle revision. The type values are
 	 *         ORed together.
 	 */
@@ -239,14 +240,14 @@ public interface BundleRevision extends 
 
 	/**
 	 * Bundle revision type indicating the bundle revision is a fragment.
-	 * 
+	 *
 	 * @see #getTypes()
 	 */
 	int	TYPE_FRAGMENT	= 0x00000001;
 
 	/**
 	 * Returns the bundle wiring which is using this bundle revision.
-	 * 
+	 *
 	 * @return The bundle wiring which is using this bundle revision or
 	 *         {@code null} if no bundle wiring is using this bundle revision.
 	 * @see BundleWiring#getRevision()

Modified: felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleWire.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleWire.java?rev=1187468&r1=1187467&r2=1187468&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleWire.java (original)
+++ felix/sandbox/rickhall/framework-r5/src/main/java/org/osgi/framework/wiring/BundleWire.java Fri Oct 21 17:07:06 2011
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) OSGi Alliance (2011). All Rights Reserved.
- * 
+ *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
@@ -16,24 +16,26 @@
 
 package org.osgi.framework.wiring;
 
+import org.osgi.framework.resource.Wire;
+
 /**
  * A wire connecting a {@link BundleCapability} to a {@link BundleRequirement}.
- * 
+ *
  * @ThreadSafe
  * @noimplement
  * @version $Id: 4f936a84065762ec3267a44f86ae01b0150e44ce $
  */
-public interface BundleWire {
+public interface BundleWire extends Wire {
 	/**
 	 * Returns the {@link BundleCapability} for this wire.
-	 * 
+	 *
 	 * @return The {@link BundleCapability} for this wire.
 	 */
 	BundleCapability getCapability();
 
 	/**
 	 * Return the {@link BundleRequirement} for this wire.
-	 * 
+	 *
 	 * @return The {@link BundleRequirement} for this wire.
 	 */
 	BundleRequirement getRequirement();
@@ -41,12 +43,12 @@ public interface BundleWire {
 	/**
 	 * Returns the bundle wiring {@link BundleWiring#getProvidedWires(String)
 	 * providing} the {@link #getCapability() capability}.
-	 * 
+	 *
 	 * <p>
 	 * The bundle revision referenced by the returned bundle wiring may differ
 	 * from the bundle revision reference by the {@link #getCapability()
 	 * capability}.
-	 * 
+	 *
 	 * @return The bundle wiring providing the capability. If the bundle wiring
 	 *         providing the capability is not {@link BundleWiring#isInUse() in
 	 *         use}, {@code null} will be returned.
@@ -57,12 +59,12 @@ public interface BundleWire {
 	 * Returns the bundle wiring who
 	 * {@link BundleWiring#getRequiredWires(String) requires} the
 	 * {@link #getCapability() capability}.
-	 * 
+	 *
 	 * <p>
 	 * The bundle revision referenced by the returned bundle wiring may differ
 	 * from the bundle revision reference by the {@link #getRequirement()
 	 * requirement}.
-	 * 
+	 *
 	 * @return The bundle wiring whose requirement is wired to the capability.
 	 *         If the bundle wiring requiring the capability is not
 	 *         {@link BundleWiring#isInUse() in use}, {@code null} will be