From 7ff171f5df081a73bae0a405d59de09e11eb62cd Mon Sep 17 00:00:00 2001 From: rfeng Date: Fri, 30 Jan 2009 07:07:16 +0000 Subject: Revert the changes to pass args[] into EquinoxHost. We should use system properties or config.ini instead git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@739196 13f79535-47bb-0310-9956-ffa450edef68 --- .../equinox/launcher/DomainManagerLauncher.java | 2 +- .../sca/node/equinox/launcher/EquinoxHost.java | 74 ++++++++++++++-------- .../node/equinox/launcher/NodeDaemonLauncher.java | 2 +- .../sca/node/equinox/launcher/NodeLauncher.java | 13 ++-- .../equinox/launcher/NodeLauncherTestCase.java | 2 +- 5 files changed, 54 insertions(+), 39 deletions(-) (limited to 'java/sca/modules/node-launcher-equinox/src') diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/DomainManagerLauncher.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/DomainManagerLauncher.java index 9078aca098..e6f59e1b07 100644 --- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/DomainManagerLauncher.java +++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/DomainManagerLauncher.java @@ -83,7 +83,7 @@ public class DomainManagerLauncher { try { // Start the OSGi host - equinox = new EquinoxHost(args); + equinox = new EquinoxHost(); equinox.start(); // Start the domain manager diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java index 912f15dde6..945e67cb3f 100644 --- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java +++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java @@ -38,6 +38,7 @@ import java.net.URL; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.ArrayList; +import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -74,8 +75,6 @@ public class EquinoxHost { private List installedBundles = new ArrayList(); private Set bundleLocations; - private String[] arguments = {}; - public EquinoxHost() { super(); } @@ -85,13 +84,6 @@ public class EquinoxHost { this.bundleLocations = urls; } - public EquinoxHost(String[] args) { - super(); - if (args != null) { - this.arguments = args; - } - } - private static String getSystemProperty(final String name) { return AccessController.doPrivileged(new PrivilegedAction() { public String run() { @@ -99,6 +91,29 @@ public class EquinoxHost { } }); } + + private static Properties getSystemProperties() { + return AccessController.doPrivileged(new PrivilegedAction() { + public Properties run() { + Properties props = new Properties(); + for (Map.Entry e : System.getProperties().entrySet()) { + if (e.getKey() instanceof String) { + String prop = (String)e.getKey(); + if (prop.startsWith("osgi.") || prop.startsWith("eclipse.")) { + props.put(prop, e.getValue()); + } + } + } + return props; + } + }); + } + + private static void put(Properties props, String key, String value) { + if (!props.contains(key)) { + props.put(key, value); + } + } /** * Start the Equinox host. @@ -120,13 +135,16 @@ public class EquinoxHost { props.load(is); is.close(); } + + props.putAll(getSystemProperties()); + // Configure Eclipse properties // Use the boot classloader as the parent classloader - props.put("osgi.contextClassLoaderParent", "app"); + put(props, "osgi.contextClassLoaderParent", "app"); // Set startup properties - props.put(EclipseStarter.PROP_CLEAN, "true"); + put(props, EclipseStarter.PROP_CLEAN, "true"); // Set location properties // FIXME Use proper locations @@ -135,23 +153,27 @@ public class EquinoxHost { if (logger.isLoggable(Level.FINE)) { logger.fine("Equinox location: " + root); } - if (!props.contains(LocationManager.PROP_INSTANCE_AREA)) { - props.put(LocationManager.PROP_INSTANCE_AREA, new File(root, "workspace").toURI().toString()); - } - if (!props.contains(LocationManager.PROP_INSTALL_AREA)) { - props.put(LocationManager.PROP_INSTALL_AREA, new File(root, "install").toURI().toString()); - } - if (!props.contains(LocationManager.PROP_CONFIG_AREA)) { - props.put(LocationManager.PROP_CONFIG_AREA, new File(root, "config").toURI().toString()); - } - if (!props.contains(LocationManager.PROP_USER_AREA)) { - props.put(LocationManager.PROP_USER_AREA, new File(root, "user").toURI().toString()); - } + + put(props, LocationManager.PROP_INSTANCE_AREA, new File(root, "workspace").toURI().toString()); + put(props, LocationManager.PROP_INSTALL_AREA, new File(root, "install").toURI().toString()); + put(props, LocationManager.PROP_CONFIG_AREA, new File(root, "config").toURI().toString()); + put(props, LocationManager.PROP_USER_AREA, new File(root, "user").toURI().toString()); EclipseStarter.setInitialProperties(props); + + // Test if the configuration/config.ini or osgi.bundles has been set + // If yes, try to avoid discovery of bundles + if (bundleLocations == null) { + String config = props.getProperty(LocationManager.PROP_CONFIG_AREA); + File ini = new File(config, "config.ini"); + if (ini.isFile() || props.getProperty("osgi.bundles") != null) { + bundleLocations = Collections.emptySet(); + } + } + // Start Eclipse - bundleContext = EclipseStarter.startup(arguments, null); + bundleContext = EclipseStarter.startup(new String[] {}, null); startedEclipse = true; } else { @@ -381,8 +403,4 @@ public class EquinoxHost { this.bundleLocations = bundleLocations; } - public void setArguments(String[] arguments) { - this.arguments = arguments; - } - } diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeDaemonLauncher.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeDaemonLauncher.java index fac714db90..aeb29c0789 100644 --- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeDaemonLauncher.java +++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeDaemonLauncher.java @@ -72,7 +72,7 @@ public class NodeDaemonLauncher { try { // Start the OSGi host - equinox = new EquinoxHost(args); + equinox = new EquinoxHost(); equinox.start(); // Start the node diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java index fe54188741..462246f37c 100644 --- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java +++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncher.java @@ -41,8 +41,8 @@ public class NodeLauncher { /** * Constructs a new node launcher. */ - private NodeLauncher(String args[]) { - equinoxHost = new EquinoxHost(args); + private NodeLauncher() { + equinoxHost = new EquinoxHost(); bundleContext = equinoxHost.start(); } @@ -51,13 +51,10 @@ public class NodeLauncher { * * @return a new launcher instance */ - public static NodeLauncher newInstance(String[] args) { - return new NodeLauncher(args); + public static NodeLauncher newInstance() { + return new NodeLauncher(); } - public static NodeLauncher newInstance() { - return new NodeLauncher(null); - } /** * Creates a new SCA node from the configuration URL * @@ -104,7 +101,7 @@ public class NodeLauncher { logger.info("Apache Tuscany SCA Node is starting..."); // Create a node launcher - NodeLauncher launcher = newInstance(args); + NodeLauncher launcher = newInstance(); EquinoxHost equinox = launcher.equinoxHost; Object node = null; diff --git a/java/sca/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java b/java/sca/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java index 9d7059eab8..6186b1799a 100644 --- a/java/sca/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java +++ b/java/sca/modules/node-launcher-equinox/src/test/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherTestCase.java @@ -34,7 +34,7 @@ public class NodeLauncherTestCase { @BeforeClass public static void setUp() { try { - launcher = NodeLauncher.newInstance(null); + launcher = NodeLauncher.newInstance(); } catch (Exception e) { e.printStackTrace(); } -- cgit v1.2.3