felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rickh...@apache.org
Subject svn commit: r1199155 - /felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
Date Tue, 08 Nov 2011 08:32:38 GMT
Author: rickhall
Date: Tue Nov  8 08:32:38 2011
New Revision: 1199155

URL: http://svn.apache.org/viewvc?rev=1199155&view=rev
Log:
Need to alias system bundle name for bundle/host capabilities. (FELIX-3205)

Modified:
    felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java

Modified: felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java?rev=1199155&r1=1199154&r2=1199155&view=diff
==============================================================================
--- felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java (original)
+++ felix/trunk/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java Tue
Nov  8 08:32:38 2011
@@ -241,10 +241,34 @@ class ExtensionManager extends URLStream
 
         List<BundleCapability> aliasCaps = new ArrayList<BundleCapability>(caps);
 
+        String[] aliases = {
+            FelixConstants.SYSTEM_BUNDLE_SYMBOLICNAME,
+            Constants.SYSTEM_BUNDLE_SYMBOLICNAME };
+
         for (int capIdx = 0; capIdx < aliasCaps.size(); capIdx++)
         {
-            // Get the attributes and search for bundle symbolic name.
-            for (Entry<String, Object> entry : aliasCaps.get(capIdx).getAttributes().entrySet())
+            BundleCapability cap = aliasCaps.get(capIdx);
+
+            // Need to alias bundle and host capabilities.
+            if (cap.getNamespace().equals(BundleRevision.BUNDLE_NAMESPACE)
+                || cap.getNamespace().equals(BundleRevision.HOST_NAMESPACE))
+            {
+                // Make a copy of the attribute array.
+                Map<String, Object> aliasAttrs =
+                    new HashMap<String, Object>(cap.getAttributes());
+                // Add the aliased value.
+                aliasAttrs.put(cap.getNamespace(), aliases);
+                // Create the aliased capability to replace the old capability.
+                cap = new BundleCapabilityImpl(
+                    cap.getRevision(),
+                    cap.getNamespace(),
+                    cap.getDirectives(),
+                    aliasAttrs);
+                aliasCaps.set(capIdx, cap);
+            }
+
+            // Further, search attributes for bundle symbolic name and alias it too.
+            for (Entry<String, Object> entry : cap.getAttributes().entrySet())
             {
                 // If there is a bundle symbolic name attribute, add the
                 // standard alias as a value.
@@ -252,18 +276,14 @@ class ExtensionManager extends URLStream
                 {
                     // Make a copy of the attribute array.
                     Map<String, Object> aliasAttrs =
-                        new HashMap<String, Object>(aliasCaps.get(capIdx).getAttributes());
+                        new HashMap<String, Object>(cap.getAttributes());
                     // Add the aliased value.
-                    aliasAttrs.put(
-                        Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE,
-                        new String[] {
-                            (String) entry.getValue(),
-                            Constants.SYSTEM_BUNDLE_SYMBOLICNAME});
+                    aliasAttrs.put(Constants.BUNDLE_SYMBOLICNAME_ATTRIBUTE, aliases);
                     // Create the aliased capability to replace the old capability.
                     aliasCaps.set(capIdx, new BundleCapabilityImpl(
-                        caps.get(capIdx).getRevision(),
-                        caps.get(capIdx).getNamespace(),
-                        caps.get(capIdx).getDirectives(),
+                        cap.getRevision(),
+                        cap.getNamespace(),
+                        cap.getDirectives(),
                         aliasAttrs));
                     // Continue with the next capability.
                     break;



Mime
View raw message