Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@minotaur.apache.org Received: (qmail 31667 invoked from network); 14 Feb 2009 15:25:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Feb 2009 15:25:05 -0000 Received: (qmail 34725 invoked by uid 500); 14 Feb 2009 15:25:05 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 34682 invoked by uid 500); 14 Feb 2009 15:25:05 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 34673 invoked by uid 99); 14 Feb 2009 15:25:05 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Feb 2009 07:25:05 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 14 Feb 2009 15:25:04 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E2D5F238898E; Sat, 14 Feb 2009 15:24:43 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: sling-commits@incubator.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20090214152443.E2D5F238898E@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 - * org.osgi.framework.executionenvironment 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 + * org.osgi.framework.executionenvironment 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 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 --------------------------------------------