Implement generic capabilities for the system bundle. (FELIX_3502)


git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1149620 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java b/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
index 16e6f46..98e1933 100644
--- a/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
+++ b/framework/src/main/java/org/apache/felix/framework/ExtensionManager.java
@@ -181,23 +181,42 @@
         // We must construct the system bundle's export metadata.
         // Get configuration property that specifies which class path
         // packages should be exported by the system bundle.
-        String syspkgs = (String) m_configMap.get(FelixConstants.FRAMEWORK_SYSTEMPACKAGES);
+        String syspkgs =
+            (String) m_configMap.get(FelixConstants.FRAMEWORK_SYSTEMPACKAGES);
         // If no system packages were specified, load our default value.
         syspkgs = (syspkgs == null)
             ? Util.getDefaultProperty(logger, Constants.FRAMEWORK_SYSTEMPACKAGES)
             : syspkgs;
         syspkgs = (syspkgs == null) ? "" : syspkgs;
         // If any extra packages are specified, then append them.
-        String extra = (String) m_configMap.get(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA);
-        syspkgs = (extra == null) ? syspkgs : syspkgs + "," + extra;
+        String pkgextra =
+            (String) m_configMap.get(FelixConstants.FRAMEWORK_SYSTEMPACKAGES_EXTRA);
+        syspkgs = (pkgextra == null) ? syspkgs : syspkgs + "," + pkgextra;
         m_headerMap.put(FelixConstants.BUNDLE_MANIFESTVERSION, "2");
         m_headerMap.put(FelixConstants.EXPORT_PACKAGE, syspkgs);
+
+        // The system bundle alsp provides framework generic capabilities
+        // as well as arbitrary user-defined generic capabilities. We must
+        // construct the system bundle's capabilitie metadata. Get the
+        // configuration property that specifies which capabilities should
+        // be provided by the system bundle.
+        String syscaps =
+            (String) m_configMap.get(FelixConstants.FRAMEWORK_SYSTEMCAPABILITIES);
+        // If no system capabilities were specified, load our default value.
+        syscaps = (syscaps == null)
+            ? Util.getDefaultProperty(logger, Constants.FRAMEWORK_SYSTEMCAPABILITIES)
+            : syscaps;
+        syscaps = (syscaps == null) ? "" : syscaps;
+        // If any extra capabilities are specified, then append them.
+        String capextra =
+            (String) m_configMap.get(FelixConstants.FRAMEWORK_SYSTEMCAPABILITIES_EXTRA);
+        syscaps = (capextra == null) ? syscaps : syscaps + "," + capextra;
+        m_headerMap.put(FelixConstants.PROVIDE_CAPABILITY, syscaps);
         try
         {
             ManifestParser mp = new ManifestParser(
                 m_logger, m_configMap, m_systemBundleRevision, m_headerMap);
-            List<BundleCapability> caps = aliasSymbolicName(mp.getCapabilities());
-            setCapabilities(caps);
+            setCapabilities(mp.getCapabilities());
         }
         catch (Exception ex)
         {
diff --git a/framework/src/main/resources/default.properties b/framework/src/main/resources/default.properties
index bba4fd6..fbfc488 100644
--- a/framework/src/main/resources/default.properties
+++ b/framework/src/main/resources/default.properties
@@ -18,6 +18,25 @@
 #
 # Framework config properties.
 #
+
+# New-style generic execution environment capabilities.
+org.osgi.framework.system.capabilities= \
+ ${dollar}{eecap-${dollar}{java.specification.version}}
+
+eecap-1.7= osgi.ee; osgi.ee="OSGi/Minimum"; version:List<Version>="1.0,1.1,1.2", \
+ osgi.ee; osgi.ee="JavaSE"; version:List<Version>="1.2,1.3,1.4,1.5,1.6,1.7"
+eecap-1.6= osgi.ee; osgi.ee="OSGi/Minimum"; version:List<Version>="1.0,1.1,1.2", \
+ osgi.ee; osgi.ee="JavaSE"; version:List<Version>="1.2,1.3,1.4,1.5,1.6"
+eecap-1.5= osgi.ee; osgi.ee="OSGi/Minimum"; version:List<Version>="1.0,1.1,1.2", \
+ osgi.ee; osgi.ee="JavaSE"; version:List<Version>="1.2,1.3,1.4,1.5"
+eecap-1.4= osgi.ee; osgi.ee="OSGi/Minimum"; version:List<Version>="1.0,1.1,1.2", \
+ osgi.ee; osgi.ee="JavaSE"; version:List<Version>="1.2,1.3,1.4"
+eecap-1.3= osgi.ee; osgi.ee="OSGi/Minimum"; version:List<Version>="1.0,1.1", \
+ osgi.ee; osgi.ee="JavaSE"; version:List<Version>="1.2,1.3"
+eecap-1.2= osgi.ee; osgi.ee="OSGi/Minimum"; version:List<Version>="1.0,1.1", \
+ osgi.ee; osgi.ee="JavaSE"; version:List<Version>="1.2"
+
+# Deprecated old-style execution environment properties.
 org.osgi.framework.executionenvironment= \
  ${dollar}{ee-${dollar}{java.specification.version}}
 
@@ -27,7 +46,9 @@
 ee-1.5=J2SE-1.5,J2SE-1.4,J2SE-1.3,OSGi/Minimum-1.2,OSGi/Minimum-1.1,OSGi/Minimum-1.0
 ee-1.4=J2SE-1.4,J2SE-1.3,OSGi/Minimum-1.2,OSGi/Minimum-1.1,OSGi/Minimum-1.0
 ee-1.3=J2SE-1.3,OSGi/Minimum-1.1,OSGi/Minimum-1.0
+ee-1.2=J2SE-1.2,OSGi/Minimum-1.1,OSGi/Minimum-1.0
 
+# Default packages exported by system bundle.
 org.osgi.framework.system.packages=org.osgi.framework; version=1.6.0, \
  org.osgi.framework.launch; version=1.0.0, \
  org.osgi.framework.wiring; version=1.0.0, \