Bug 105851 - Allow per instance configuration of the framework
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java index 21377b7..904fa3e 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/InternalPlatform.java
@@ -126,6 +126,8 @@ private boolean missingProductReported = false; private IProduct product; private AdapterManagerListener adapterManagerListener = null; + private String applicationId; + private Properties commandLineProperties = new Properties(); private Plugin runtimeInstance; // Keep track of the plugin object for runtime in case the backward compatibility is run. @@ -222,6 +224,28 @@ return appArgs; } + public String getApplicationId() { + if (applicationId != null) + return applicationId; + + // try commandLineProperties + applicationId = commandLineProperties.getProperty(PROP_APPLICATION); + if (applicationId != null) + return applicationId; + + // try bundleContext properties + applicationId = context.getProperty(PROP_APPLICATION); + if (applicationId != null) + return applicationId; + + //Derive the application from the product information + IProduct eclipseProduct = getProduct(); + if (eclipseProduct != null) { + applicationId = eclipseProduct.getApplication(); + } + return applicationId; + } + public Map getAuthorizationInfo(URL serverUrl, String realm, String authScheme) { return AuthorizationHandler.getAuthorizationInfo(serverUrl, realm, authScheme); } @@ -574,9 +598,16 @@ public IProduct getProduct() { if (product != null) return product; - String productId = System.getProperty(InternalPlatform.PROP_PRODUCT); - if (productId == null) - return null; + + // try commandLineProperties + String productId = commandLineProperties.getProperty(PROP_PRODUCT); + + if (productId == null) { + // try bundleContext properties + productId = context.getProperty(InternalPlatform.PROP_PRODUCT); + if (productId == null) + return null; + } IConfigurationElement[] entries = InternalPlatform.getDefault().getRegistry().getConfigurationElementsFor(Platform.PI_RUNTIME, Platform.PT_PRODUCT, productId); if (entries.length > 0) { // There should only be one product with the given id so just take the first element @@ -875,14 +906,14 @@ // treat -feature as a synonym for -product for compatibility. if (args[i - 1].equalsIgnoreCase(PRODUCT) || args[i - 1].equalsIgnoreCase(FEATURE)) { // use the long way to set the property to compile against eeminimum - System.getProperties().setProperty(PROP_PRODUCT, arg); + commandLineProperties.setProperty(PROP_PRODUCT, arg); found = true; } // look for the application to run. if (args[i - 1].equalsIgnoreCase(APPLICATION)) { // use the long way to set the property to compile against eeminimum - System.getProperties().setProperty(PROP_APPLICATION, arg); + commandLineProperties.setProperty(PROP_APPLICATION, arg); found = true; }
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformActivator.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformActivator.java index 725b1f0..1f773ff 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformActivator.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/internal/runtime/PlatformActivator.java
@@ -72,17 +72,7 @@ ParameterizedRunnable work = new ParameterizedRunnable() { public Object run(Object arg) throws Exception { IPlatformRunnable application = null; - String applicationId = System.getProperty(PROP_ECLIPSE_APPLICATION); - if (applicationId == null) { - //Derive the application from the product information - IProduct product = InternalPlatform.getDefault().getProduct(); - if (product != null) { - applicationId = product.getApplication(); - if (applicationId != null) - // use the long way to set the property to compile against eeminimum - System.getProperties().setProperty(PROP_ECLIPSE_APPLICATION, applicationId); - } - } + String applicationId = InternalPlatform.getDefault().getApplicationId(); if (applicationId == null) throw new RuntimeException(Messages.application_noIdFound); IExtensionRegistry registry = InternalPlatform.getDefault().getRegistry();
diff --git a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java index 85d5d19..0a40537 100644 --- a/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java +++ b/bundles/org.eclipse.core.runtime/src/org/eclipse/core/runtime/Platform.java
@@ -463,6 +463,7 @@ * @param listener the listener to register * @see ILog#addLogListener(ILogListener) * @see #removeLogListener(ILogListener) + * XXX Use the LogMgr service. */ public static void addLogListener(ILogListener listener) { InternalPlatform.getDefault().addLogListener(listener); @@ -1474,7 +1475,7 @@ * @since 3.0 */ public static boolean inDebugMode() { - return System.getProperty("osgi.debug") != null; //$NON-NLS-1$ + return PlatformActivator.getContext().getProperty("osgi.debug") != null; //$NON-NLS-1$ } /** @@ -1490,6 +1491,6 @@ * @since 3.0 */ public static boolean inDevelopmentMode() { - return System.getProperty("osgi.dev") != null; //$NON-NLS-1$ + return PlatformActivator.getContext().getProperty("osgi.dev") != null; //$NON-NLS-1$ } }