diff options
author | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-15 22:07:43 +0000 |
---|---|---|
committer | rfeng <rfeng@13f79535-47bb-0310-9956-ffa450edef68> | 2008-08-15 22:07:43 +0000 |
commit | b260755836736d405f104bfc14111cb9d51f8118 (patch) | |
tree | bb7eb118adeef50761cf6b72bb6b789251d78f88 /java/sca/modules/node2-launcher/src | |
parent | 1c22b82f37a62e40036cd8fdf70918fd7fc93bd0 (diff) |
Port DefaultSCADomain to use SCA Node impl
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@686391 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/node2-launcher/src')
-rw-r--r-- | java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java b/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java index e962491b25..f0c0a0a2f4 100644 --- a/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java +++ b/java/sca/modules/node2-launcher/src/main/java/org/apache/tuscany/sca/node/launcher/DomainManagerLauncher.java @@ -72,7 +72,7 @@ public class DomainManagerLauncher { } public static void main(String[] args) throws Exception { - logger.info("Apache Tuscany SCA Domain Manager starting..."); + logger.info("Apache Tuscany SCA Domain Manager is starting..."); // Create a domain manager DomainManagerLauncher launcher = newInstance(); @@ -85,9 +85,13 @@ public class DomainManagerLauncher { logger.log(Level.SEVERE, "SCA Domain Manager could not be started", e); throw e; } - logger.info("SCA Domain Manager started."); + logger.info("SCA Domain Manager is now started."); + + ShutdownThread hook = new ShutdownThread(domainManager); + Runtime.getRuntime().addShutdownHook(hook); logger.info("Press enter to shutdown."); + try { System.in.read(); } catch (IOException e) { @@ -98,13 +102,40 @@ public class DomainManagerLauncher { lock.wait(); } } + + stop(domainManager); + // Remove the hook + Runtime.getRuntime().removeShutdownHook(hook); + } + private static void stop(Object domainManager) throws Exception { // Stop the domain manager + if (domainManager == null) { + return; + } try { domainManager.getClass().getMethod("stop").invoke(domainManager); + logger.info("SCA Domain Manager is now stopped."); } catch (Exception e) { logger.log(Level.SEVERE, "SCA Domain Manager could not be stopped", e); throw e; } } + + private static class ShutdownThread extends Thread { + private Object domainManager; + + public ShutdownThread(Object domainManager) { + super(); + this.domainManager = domainManager; + } + + public void run() { + try { + DomainManagerLauncher.stop(domainManager); + } catch (Exception e) { + // Ignore + } + } + } } |