diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-10 17:28:19 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-10 17:28:19 +0000 |
commit | 0eafdd619cefb1f9980a6d9e2309d11c444187ff (patch) | |
tree | 7b2adde7b533b882f6619771fe76e4050c672509 /java/sca/modules/node-launcher-equinox/src/main | |
parent | a3e32f58df8108d7ddb4728e13d3a4829b4a698d (diff) |
Minor simplification of node-launcher-equinox, which doesn't need a BundleActivator anymore.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@693906 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/node-launcher-equinox/src/main')
-rw-r--r-- | java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxHost.java | 28 | ||||
-rw-r--r-- | java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java (renamed from java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LauncherBundleActivator.java) | 15 |
2 files changed, 30 insertions, 13 deletions
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 06bc1907b4..63313b6f39 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 @@ -46,7 +46,9 @@ import org.osgi.framework.BundleContext; public class EquinoxHost { private static Logger logger = Logger.getLogger(EquinoxHost.class.getName()); - private BundleContext context; + private BundleContext bundleContext; + private Bundle launcherBundle; + private EquinoxLauncherBundleHelper launcherActivator; private final static String systemPackages = "org.osgi.framework; version=1.3.0," + "org.osgi.service.packageadmin; version=1.2.0, " @@ -149,18 +151,22 @@ public class EquinoxHost { EclipseStarter.setInitialProperties(props); // Start Eclipse - context = EclipseStarter.startup(new String[]{}, null); + bundleContext = EclipseStarter.startup(new String[]{}, null); // Install the launcher bundle String bundleLocation = bundleLocation(); logger.info("Installing launcher bundle: " + bundleLocation); - Bundle launcherBundle = context.installBundle(bundleLocation); + launcherBundle = bundleContext.installBundle(bundleLocation); logger.info("Starting bundle: " + string(launcherBundle, false)); launcherBundle.start(); + // Manually call the LauncherBundleActivator for now + launcherActivator = new EquinoxLauncherBundleHelper(); + launcherActivator.start(launcherBundle.getBundleContext()); + // Start all bundles for now to help diagnose any class loading issues long activateStart = System.currentTimeMillis(); - for (Bundle bundle: context.getBundles()) { + for (Bundle bundle: bundleContext.getBundles()) { if ((bundle.getState() & Bundle.ACTIVE) == 0) { logger.info("Starting bundle: " + string(bundle, false)); try { @@ -172,7 +178,7 @@ public class EquinoxHost { } } logger.info("Tuscany bundles are started in " + (System.currentTimeMillis() - activateStart) + " ms."); - return context; + return bundleContext; } catch (Exception e) { throw new IllegalStateException(e); @@ -181,7 +187,19 @@ public class EquinoxHost { public void stop() { try { + + // Uninstall the launcher bundle + if (launcherActivator != null) { + launcherActivator.stop(launcherBundle.getBundleContext()); + } + if (launcherBundle != null) { + logger.info("Uninstalling bundle: " + string(launcherBundle, false)); + launcherBundle.uninstall(); + } + + // Shutdown Eclipse EclipseStarter.shutdown(); + } catch (Exception e) { throw new IllegalStateException(e); } diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LauncherBundleActivator.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java index 4e790fc015..97cc094f2b 100644 --- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/LauncherBundleActivator.java +++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxLauncherBundleHelper.java @@ -9,23 +9,21 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.osgi.framework.Bundle; -import org.osgi.framework.BundleActivator; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleEvent; import org.osgi.framework.BundleListener; -import org.osgi.framework.Constants; /** * Bundle activator which installs Tuscany modules into an OSGi runtime. * */ -public class LauncherBundleActivator implements BundleActivator, Constants, BundleListener { - private static Logger logger = Logger.getLogger(LauncherBundleActivator.class.getName()); +public class EquinoxLauncherBundleHelper implements BundleListener { + private static Logger logger = Logger.getLogger(EquinoxLauncherBundleHelper.class.getName()); private List<Bundle> installedBundles = new ArrayList<Bundle>(); private BundleContext bundleContext; - public LauncherBundleActivator() { + public EquinoxLauncherBundleHelper() { super(); } @@ -47,8 +45,8 @@ public class LauncherBundleActivator implements BundleActivator, Constants, Bund long libraryStart = System.currentTimeMillis(); //InputStream library = NodeLauncherUtil.libraryBundle(jarFiles); Bundle libraryBundle = bundleContext.installBundle("org.apache.tuscany.sca.node.launcher.equinox.libraries", new ByteArrayInputStream(new byte[0])); - installedBundles.add(libraryBundle); logger.info("Third-party library bundle installed in " + (System.currentTimeMillis() - libraryStart) + " ms: " + NodeLauncherUtil.string(libraryBundle, false)); + installedBundles.add(libraryBundle); // Get the set of already installed bundles Set<String> alreadyInstalledBundleNames = new HashSet<String>(); @@ -84,10 +82,11 @@ public class LauncherBundleActivator implements BundleActivator, Constants, Bund public void stop(BundleContext bundleContext) throws Exception { // Uninstall all the bundles we've installed - for (Bundle bundle : installedBundles) { + for (int i = installedBundles.size() -1; i >= 0; i--) { + Bundle bundle = installedBundles.get(i); try { //if (logger.isLoggable(Level.FINE)) { - // logger.info("Uninstalling bundle: " + NodeLauncherUtil.string(bundle, false)); + logger.info("Uninstalling bundle: " + NodeLauncherUtil.string(bundle, false)); //} bundle.uninstall(); } catch (Exception e) { |