felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r909976 - /felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/FelixResolverState.java
Date Sun, 14 Feb 2010 06:15:25 GMT
Author: rickhall
Date: Sun Feb 14 06:15:25 2010
New Revision: 909976

URL: http://svn.apache.org/viewvc?rev=909976&view=rev
Log:
Use capability set for indexing fragment hosts.

Modified:
    felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/FelixResolverState.java

Modified: felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/FelixResolverState.java
URL: http://svn.apache.org/viewvc/felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/FelixResolverState.java?rev=909976&r1=909975&r2=909976&view=diff
==============================================================================
--- felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/FelixResolverState.java
(original)
+++ felix/sandbox/rickhall/framework-proto/src/main/java/org/apache/felix/framework/FelixResolverState.java
Sun Feb 14 06:15:25 2010
@@ -48,6 +48,8 @@
     private final CapabilitySet m_modCapSet;
     // Capability set for packages.
     private final CapabilitySet m_pkgCapSet;
+    // Capability set for hosts.
+    private final CapabilitySet m_hostCapSet;
     // Maps fragment symbolic names to list of fragment modules sorted by version.
     private final Map<String, List<Module>> m_fragmentMap = new HashMap();
     // Maps singleton symbolic names to list of modules sorted by version.
@@ -66,6 +68,9 @@
         indices.add(Capability.PACKAGE_ATTR);
         m_pkgCapSet = new CapabilitySet(indices);
 
+        indices = new ArrayList();
+        indices.add(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE);
+        m_hostCapSet = new CapabilitySet(indices);
     }
 
     public synchronized void addModule(Module module)
@@ -412,32 +417,26 @@
                 return matchingHosts;
             }
         }
-        for (int hostIdx = 0; (hostReq != null) && (hostIdx < m_modules.size());
hostIdx++)
+
+        Set<Capability> hostCaps = m_hostCapSet.match(hostReq.getFilter(), true);
+
+        for (Capability hostCap : hostCaps)
         {
-            Module host = m_modules.get(hostIdx);
             // Only look at unresolved hosts, since we don't support
             // dynamic attachment of fragments.
-            if (host.isResolved()
-                || ((BundleImpl) host.getBundle()).isStale()
-                || ((BundleImpl) host.getBundle()).isRemovalPending())
+            if (hostCap.getModule().isResolved()
+                || ((BundleImpl) hostCap.getModule().getBundle()).isStale()
+                || ((BundleImpl) hostCap.getModule().getBundle()).isRemovalPending())
             {
                 continue;
             }
 
-            // Find the host capability for the current host.
-            Capability hostCap = Util.getSatisfyingCapability(host, hostReq);
-
-            // If there is no host capability in the current module,
-            // then just ignore it.
-            if (hostCap == null)
-            {
-                continue;
-            }
-            
             if (sm != null)
             {
-                if (!((BundleProtectionDomain) host.getSecurityContext()).impliesDirect(new
BundlePermission(host.getSymbolicName(), 
-                    BundlePermission.HOST)))
+                if (!((BundleProtectionDomain) hostCap.getModule()
+                        .getSecurityContext()).impliesDirect(
+                            new BundlePermission(hostCap.getModule().getSymbolicName(),
+                            BundlePermission.HOST)))
                 {
                     continue;
                 }
@@ -455,6 +454,11 @@
         // into the host and then second create an aggregated list of unresolved
         // capabilities to simplify later processing when resolving bundles.
         m_modules.add(host);
+        List<Capability> caps = Util.getCapabilityByNamespace(host, Capability.HOST_NAMESPACE);
+        if (caps.size() > 0)
+        {
+            m_hostCapSet.addCapability(caps.get(0));
+        }
 
         //
         // First, merge applicable fragments.
@@ -489,7 +493,7 @@
         // Second, index module's capabilities.
         //
 
-        List<Capability> caps = host.getCapabilities();
+        caps = host.getCapabilities();
 
         // Add exports to unresolved package map.
         for (int i = 0; (caps != null) && (i < caps.size()); i++)
@@ -511,9 +515,14 @@
         // "unresolved" package maps, remove its dependencies on fragments
         // and exporters, and remove it from the module list.
         m_modules.remove(host);
+        List<Capability> caps = Util.getCapabilityByNamespace(host, Capability.HOST_NAMESPACE);
+        if (caps.size() > 0)
+        {
+            m_hostCapSet.removeCapability(caps.get(0));
+        }
 
         // Remove exports from package maps.
-        List<Capability> caps = host.getCapabilities();
+        caps = host.getCapabilities();
         for (int i = 0; (caps != null) && (i < caps.size()); i++)
         {
             if (caps.get(i).getNamespace().equals(Capability.MODULE_NAMESPACE))



Mime
View raw message