Added back in support for extension bundle exports. (FELIX-851)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@737915 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/Felix.java b/framework/src/main/java/org/apache/felix/framework/Felix.java
index aa9983a..7c27ea6 100644
--- a/framework/src/main/java/org/apache/felix/framework/Felix.java
+++ b/framework/src/main/java/org/apache/felix/framework/Felix.java
@@ -1598,8 +1598,9 @@
                             bundle.getCurrentModule().getHeaders()))
                     {
                         m_extensionManager.addExtensionBundle(this, bundle);
-// TODO: REFACTOR - REFRESH RESOLVER STATE.
-//                        m_factory.refreshModule(m_sbi.getCurrentModule());
+// TODO: REFACTOR - Perhaps we could move this into extension manager.
+                        m_resolverState.refreshSystemBundleModule(bundle.getCurrentModule());
+// TODO: REFACTOR - Not clear why this is here. We should look at all of these steps more closely.
                         bundle.setState(Bundle.RESOLVED);
                     }
                     else if (bundle.isExtension())
@@ -2052,8 +2053,7 @@
                 else
                 {
                     m_extensionManager.addExtensionBundle(this, bundle);
-// TODO: REFACTOR - REFRESH RESOLVER STATE.
-//                    m_factory.refreshModule(m_sbi.getCurrentModule());
+                    m_resolverState.refreshSystemBundleModule(m_extensionManager.getModule());
                 }
             }
             catch (Throwable ex)
diff --git a/framework/src/main/java/org/apache/felix/framework/FelixResolverState.java b/framework/src/main/java/org/apache/felix/framework/FelixResolverState.java
index 4e90912..46b691e 100644
--- a/framework/src/main/java/org/apache/felix/framework/FelixResolverState.java
+++ b/framework/src/main/java/org/apache/felix/framework/FelixResolverState.java
@@ -49,8 +49,6 @@
     // Maps a module to an array of capabilities.
     private final Map m_resolvedCapMap = new HashMap();
 
-    private final Map m_moduleDataMap = new HashMap();
-
     // Reusable empty array.
     private static final IModule[] m_emptyModules = new IModule[0];
     private static final PackageSource[] m_emptySources = new PackageSource[0];
@@ -136,45 +134,40 @@
         ((ModuleImpl) module).close();
 
         // Remove the module from the "resolved" map.
-// TODO: RB - Maybe this can be merged with ModuleData.
         m_resolvedCapMap.remove(module);
-        // Finally, remove module data.
-        m_moduleDataMap.remove(module);
     }
 
-/* TODO: RESOLVER - We need to figure out what to do with this.
-    public void moduleRefreshed(ModuleEvent event)
+    /**
+     * This method is used for installing system bundle extensions. It actually
+     * refreshes the system bundle module's capabilities in the resolver state
+     * to capture additional capabilities.
+     * @param module The module being refresh, which should always be the system bundle.
+    **/
+    synchronized void refreshSystemBundleModule(IModule module)
     {
-        synchronized (m_factory)
+        // The system bundle module should always be resolved, so we only need
+        // to update the resolved capability map.
+        ICapability[] caps = module.getCapabilities();
+        for (int i = 0; (caps != null) && (i < caps.length); i++)
         {
-            IModule module = event.getModule();
-            // Remove exports from package maps.
-            ICapability[] caps = event.getModule().getDefinition().getCapabilities();
-            // Add exports to unresolved package map.
-            for (int i = 0; (caps != null) && (i < caps.length); i++)
-            {
-                ICapability[] resolvedCaps = (ICapability[]) m_resolvedCapMap.get(module);
-                resolvedCaps = addCapabilityToArray(resolvedCaps, caps[i]);
-                m_resolvedCapMap.put(module, resolvedCaps);
+            ICapability[] resolvedCaps = (ICapability[]) m_resolvedCapMap.get(module);
+            resolvedCaps = addCapabilityToArray(resolvedCaps, caps[i]);
+            m_resolvedCapMap.put(module, resolvedCaps);
 
-                // If the capability is a package, then add the exporter module
-                // of the wire to the "resolved" package index and remove it
-                // from the "unresolved" package index.
-                if (caps[i].getNamespace().equals(ICapability.PACKAGE_NAMESPACE))
-                {
-                    // Get package name.
-                    String pkgName = (String)
-                        caps[i].getProperties().get(ICapability.PACKAGE_PROPERTY);
-                    // Add to "resolved" package index.
-                    indexPackageCapability(
-                        m_resolvedPkgIndexMap,
-                        module,
-                        caps[i]);
-                }
+            // If the capability is a package, then add the exporter module
+            // of the wire to the "resolved" package index and remove it
+            // from the "unresolved" package index.
+            if (caps[i].getNamespace().equals(ICapability.PACKAGE_NAMESPACE))
+            {
+                // Add to "resolved" package index.
+                indexPackageCapability(
+                    m_resolvedPkgIndexMap,
+                    module,
+                    caps[i]);
             }
         }
     }
-*/
+
     private void dumpPackageIndexMap(Map pkgIndexMap)
     {
         for (Iterator i = pkgIndexMap.entrySet().iterator(); i.hasNext(); )