diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-05 02:31:13 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2008-09-05 02:31:13 +0000 |
commit | e72d612a609795fd7194e1b03657d7beb440f428 (patch) | |
tree | f60402c60ba133be05c29f94ba064979e2161d3f /java/sca/modules/node-launcher-equinox/src | |
parent | fb240413ba1f8e320a04f889ac6cd70af94ca0c9 (diff) |
Simplified a bit the access to EquinoxOSGiHost.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@692321 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/node-launcher-equinox/src')
6 files changed, 37 insertions, 49 deletions
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 388f42bbb3..c9ee58a2a6 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 @@ -20,8 +20,6 @@ package org.apache.tuscany.sca.node.equinox.launcher; import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.domainManager; -import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.startOSGi; -import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.stopOSGi; import java.io.IOException; import java.util.logging.Level; @@ -79,13 +77,14 @@ public class DomainManagerLauncher { // Create a launcher DomainManagerLauncher launcher = newInstance(); - OSGiHost osgiHost = null; + EquinoxOSGiHost equinox = null; Object domainManager = null; ShutdownThread shutdown = null; try { // Start the OSGi host - osgiHost = startOSGi(); + equinox = new EquinoxOSGiHost(); + equinox.start(); // Start the domain manager domainManager = launcher.createDomainManager(); @@ -98,7 +97,7 @@ public class DomainManagerLauncher { logger.info("SCA Domain Manager is now started."); // Install a shutdown hook - ShutdownThread hook = new ShutdownThread(domainManager, osgiHost); + ShutdownThread hook = new ShutdownThread(domainManager, equinox); Runtime.getRuntime().addShutdownHook(hook); logger.info("Press enter to shutdown."); @@ -124,8 +123,8 @@ public class DomainManagerLauncher { if (domainManager != null) { stopDomainManager(domainManager); } - if (osgiHost != null) { - stopOSGi(osgiHost); + if (equinox != null) { + equinox.stop(); } } } @@ -149,12 +148,12 @@ public class DomainManagerLauncher { private static class ShutdownThread extends Thread { private Object domainManager; - private OSGiHost osgiHost; + private EquinoxOSGiHost equinox; - public ShutdownThread(Object domainManager, OSGiHost osgiHost) { + public ShutdownThread(Object domainManager, EquinoxOSGiHost equinox) { super(); this.domainManager = domainManager; - this.osgiHost = osgiHost; + this.equinox = equinox; } public void run() { @@ -164,7 +163,7 @@ public class DomainManagerLauncher { // Ignore } try { - stopOSGi(osgiHost); + equinox.stop(); } catch (Exception e) { // Ignore } diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxOSGiHost.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxOSGiHost.java index f94dd8e166..0a7cf67cc2 100644 --- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxOSGiHost.java +++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/EquinoxOSGiHost.java @@ -28,9 +28,9 @@ import org.eclipse.core.runtime.adaptor.LocationManager; import org.osgi.framework.BundleContext; /** - * + * Wraps the Equinox runtime. */ -public class EquinoxOSGiHost implements OSGiHost { +public class EquinoxOSGiHost { private LauncherBundleActivator activator = new LauncherBundleActivator(); private BundleContext context; 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 2eb4609da1..c589fdda25 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 @@ -20,8 +20,6 @@ package org.apache.tuscany.sca.node.equinox.launcher; import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.nodeDaemon; -import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.startOSGi; -import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.stopOSGi; import java.io.IOException; import java.util.logging.Level; @@ -68,13 +66,14 @@ public class NodeDaemonLauncher { // Create a node launcher NodeDaemonLauncher launcher = newInstance(); - OSGiHost osgiHost = null; + EquinoxOSGiHost equinox = null; Object node = null; ShutdownThread shutdown = null; try { // Start the OSGi host - osgiHost = startOSGi(); + equinox = new EquinoxOSGiHost(); + equinox.start(); // Start the node node = launcher.createNodeDaemon(); @@ -87,7 +86,7 @@ public class NodeDaemonLauncher { logger.info("SCA Node Daemon is now started."); // Install a shutdown hook - shutdown = new ShutdownThread(node, osgiHost); + shutdown = new ShutdownThread(node, equinox); Runtime.getRuntime().addShutdownHook(shutdown); logger.info("Press enter to shutdown."); @@ -112,8 +111,8 @@ public class NodeDaemonLauncher { if (node != null) { stopNode(node); } - if (osgiHost != null) { - stopOSGi(osgiHost); + if (equinox != null) { + equinox.stop(); } } } @@ -136,12 +135,12 @@ public class NodeDaemonLauncher { private static class ShutdownThread extends Thread { private Object node; - private OSGiHost osgiHost; + private EquinoxOSGiHost equinox; - public ShutdownThread(Object node, OSGiHost osgiHost) { + public ShutdownThread(Object node, EquinoxOSGiHost equinox) { super(); this.node = node; - this.osgiHost = osgiHost; + this.equinox = equinox; } public void run() { @@ -151,7 +150,7 @@ public class NodeDaemonLauncher { // Ignore } try { - stopOSGi(osgiHost); + equinox.stop(); } catch (Exception e) { // Ignore } 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 870a5d5e10..bc9e3f24f2 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 @@ -20,8 +20,6 @@ package org.apache.tuscany.sca.node.equinox.launcher; import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.node; -import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.startOSGi; -import static org.apache.tuscany.sca.node.equinox.launcher.NodeLauncherUtil.stopOSGi; import java.io.IOException; import java.util.logging.Level; @@ -117,13 +115,14 @@ public class NodeLauncher { // Create a node launcher NodeLauncher launcher = newInstance(); - OSGiHost osgiHost = null; + EquinoxOSGiHost equinox = null; Object node = null; ShutdownThread shutdown = null; try { // Start the OSGi host - osgiHost = startOSGi(); + equinox = new EquinoxOSGiHost(); + equinox.start(); if (args.length ==1) { @@ -151,7 +150,7 @@ public class NodeLauncher { logger.info("SCA Node is now started."); // Install a shutdown hook - shutdown = new ShutdownThread(node, osgiHost); + shutdown = new ShutdownThread(node, equinox); Runtime.getRuntime().addShutdownHook(shutdown); logger.info("Press enter to shutdown."); @@ -176,8 +175,8 @@ public class NodeLauncher { if (node != null) { stopNode(node); } - if (osgiHost != null) { - stopOSGi(osgiHost); + if (equinox != null) { + equinox.stop(); } } } @@ -200,12 +199,12 @@ public class NodeLauncher { private static class ShutdownThread extends Thread { private Object node; - private OSGiHost osgiHost; + private EquinoxOSGiHost equinox; - public ShutdownThread(Object node, OSGiHost osgiHost) { + public ShutdownThread(Object node, EquinoxOSGiHost equinox) { super(); this.node = node; - this.osgiHost = osgiHost; + this.equinox = equinox; } public void run() { @@ -215,7 +214,7 @@ public class NodeLauncher { // Ignore } try { - stopOSGi(osgiHost); + equinox.stop(); } catch (Exception e) { // Ignore } diff --git a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java index 89d87b21d1..e7373d529b 100644 --- a/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java +++ b/java/sca/modules/node-launcher-equinox/src/main/java/org/apache/tuscany/sca/node/equinox/launcher/NodeLauncherUtil.java @@ -172,14 +172,4 @@ final class NodeLauncherUtil { } } - static OSGiHost startOSGi() { - OSGiHost host = new EquinoxOSGiHost(); - host.start(); - return host; - } - - static void stopOSGi(OSGiHost host) { - host.stop(); - } - } 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 2bb45a38be..9e30c1695e 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 @@ -32,18 +32,19 @@ import org.junit.Test; * */ public class NodeLauncherTestCase { - private static OSGiHost host; + private static EquinoxOSGiHost equinox; @BeforeClass public static void setUp() { // System.setProperty("TUSCANY_HOME", "target/tuscany"); - host = NodeLauncherUtil.startOSGi(); + equinox = new EquinoxOSGiHost(); + equinox.start(); } @AfterClass public static void tearDown() { - if (host != null) { - NodeLauncherUtil.stopOSGi(host); + if (equinox != null) { + equinox.stop(); } } |