incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r744507 - /incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java
Date Sat, 14 Feb 2009 15:24:43 GMT
Author: fmeschbe
Date: Sat Feb 14 15:24:39 2009
New Revision: 744507

URL: http://svn.apache.org/viewvc?rev=744507&view=rev
Log:
SLING-856 Always set the OSGi execution environment

Modified:
    incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java

Modified: incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java?rev=744507&r1=744506&r2=744507&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java
(original)
+++ incubator/sling/trunk/launchpad/base/src/main/java/org/apache/sling/launchpad/base/impl/Sling.java
Sat Feb 14 15:24:39 2009
@@ -166,6 +166,16 @@
     public static final String PROP_SYSTEM_PACKAGES = "org.apache.sling.launcher.system.packages";
 
     /**
+     * List of multiple Execution Environment names supported by various
+     * Java Runtime versions.
+     * @see #setExecutionEnvironment(Map)
+     */
+    private static final String[][] EE_NAMES = { { "JRE-1.1" }, { "J2SE-1.2" },
+        { "J2SE-1.3", "OSGi/Minimum-1.0", "CDC-1.0/Foundation-1.0" },
+        { "J2SE-1.4", "OSGi/Minimum-1.1", "CDC-1.1/Foundation-1.1" },
+        { "J2SE-1.5" }, { "JavaSE-1.6" } };
+
+    /**
      * The simple logger to log messages during startup and shutdown to
      */
     protected final Logger logger;
@@ -620,13 +630,12 @@
     }
 
     /**
-     * Ensures sensible Execution Environment setting. If the
-     * <code>org.osgi.framework.executionenvironment</code> property is set in
-     * the configured properties or the system properties, we ensure that older
-     * settings for J2SE-1.2, J2SE-1.3 and J2SE-1.4 are included. If the
-     * property is neither set in the configuration properties nor in the system
-     * properties, the property is not set.
-     *
+     * Sets the correct execution environment values for the Java Runtime in
+     * which Sling is runnin. This method takes any
+     * <code>org.osgi.framework.executionenvironment</code> property already
set
+     * and ensures the older settings are included. If the property is not set
+     * yet, it is fully constructed by this method.
+     * 
      * @param props The configuration properties to check and optionally ammend.
      */
     private void setExecutionEnvironment(Map<String, String> props) {
@@ -635,32 +644,41 @@
         if (ee == null) {
             ee = System.getProperty(Constants.FRAMEWORK_EXECUTIONENVIRONMENT);
         }
-
-        // if there is a setting, ensure J2SE-1.2/3/4/5 is included in the list
+        
+        // prepare for building the new property value
+        StringBuilder eebuilder = new StringBuilder();
         if (ee != null) {
-            int javaMinor;
-            try {
-                String specVString = System.getProperty("java.specification.version");
-                javaMinor = Version.parseVersion(specVString).getMinor();
-            } catch (IllegalArgumentException iae) {
-                // don't care, assume minimal sling version (1.5)
-                javaMinor = 5;
-            }
+            eebuilder.append(ee);
+        }
+
+        // get the minor Java versions (expected to be 5, 6, or higher)
+        int javaMinor;
+        try {
+            String specVString = System.getProperty("java.specification.version");
+            javaMinor = Version.parseVersion(specVString).getMinor();
+        } catch (IllegalArgumentException iae) {
+            // don't care, assume minimal sling version (1.5)
+            javaMinor = 5;
+        }
 
-            for (int i = 2; i <= javaMinor; i++) {
-                String exEnv = "J2SE-1." + i;
-                if (ee.indexOf(exEnv) < 0) {
-                    ee += "," + exEnv;
+        // walk the list of known names and include any by java minor version
+        for (int i = 0; i < javaMinor && i < EE_NAMES.length; i++) {
+            String[] vmEENames = EE_NAMES[i];
+            for (String vmEEName : vmEENames) {
+                if (eebuilder.indexOf(vmEEName) < 0) {
+                    if (eebuilder.length() > 0) {
+                        eebuilder.append(',');
+                    }
+                    eebuilder.append(vmEEName);
                 }
             }
-
-            this.logger.log(Logger.LOG_INFO,
-                "Using Execution Environment setting: " + ee);
-            props.put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, ee);
-        } else {
-            this.logger.log(Logger.LOG_INFO,
-                "Not using Execution Environment setting");
         }
+
+        // finally set the new execution environment value
+        ee = eebuilder.toString();
+        this.logger.log(Logger.LOG_INFO,
+            "Using Execution Environment setting: " + ee);
+        props.put(Constants.FRAMEWORK_EXECUTIONENVIRONMENT, ee);
     }
 
     // ---------- Extension support --------------------------------------------



Mime
View raw message