From 067ee7cf4654e9a812865abf71d75735acb03fde Mon Sep 17 00:00:00 2001 From: antelder Date: Mon, 5 Jul 2010 19:02:07 +0000 Subject: Update stop command to support stopping individual contributions and composites git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@960660 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/tuscany/sca/shell/JLine.java | 8 ++++++- .../java/org/apache/tuscany/sca/shell/Shell.java | 26 ++++++++++++++++------ 2 files changed, 26 insertions(+), 8 deletions(-) (limited to 'sca-java-2.x/trunk/modules/shell/src/main') diff --git a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/JLine.java b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/JLine.java index 88a0e7ca51..d09a72f84f 100644 --- a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/JLine.java +++ b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/JLine.java @@ -32,6 +32,8 @@ import jline.ConsoleReader; import jline.FileNameCompletor; import jline.SimpleCompletor; +import org.apache.tuscany.sca.runtime.ActivationException; + /** * Keep all the JLine specific code out of the Shell class so that it runs ok * when jline isn't on the classpath. @@ -48,7 +50,11 @@ public class JLine { // Add a Ctrl-c listener reader.addTriggeredAction((char)3, new ActionListener() { public void actionPerformed(ActionEvent e) { - shell.stop(); + try { + shell.stop(null); + } catch (ActivationException e1) { + e1.printStackTrace(); + } System.exit(0); } }); diff --git a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java index a8ed16c5ff..75b7a5c4ba 100644 --- a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java +++ b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java @@ -180,14 +180,26 @@ public class Shell { out.println(" listInstalledContributions"); out.println(" printDomainLevelComposite"); out.println(" status [ ]"); - out.println(" stop"); + out.println(" stop [ ]"); out.println(); return true; } - boolean stop() { - node.stop(); - return false; + boolean stop(List toks) throws ActivationException { + if (toks == null || toks.size() < 2) { + node.stop(); + return false; + } + String curi = toks.get(1); + if (toks.size() > 2) { + node.removeFromDomainLevelComposite(curi + "/" + toks.get(2)); + } else { + for (String compositeURI : node.getDeployedCompostes(curi)) { + node.removeFromDomainLevelComposite(curi + "/" + compositeURI); + } + } + + return true; } boolean status(final List toks) { @@ -211,7 +223,7 @@ public class Shell { } for (String compositeUri : dcs) { for (Artifact a : c.getArtifacts()) { - if (compositeUri.equals(curi + "/" + a.getURI())) { + if (compositeUri.equals(a.getURI())) { out.println(" " + curi + " " + c.getLocation() + " " + compositeUri + " " + ((Composite)a.getModel()).getName()); } } @@ -272,8 +284,8 @@ public class Shell { if (op.equals("help")) return new Callable() { public Boolean call() { return help(); }}; - if (op.equals("stop")) return new Callable() { public Boolean call() { - return stop(); + if (op.equals("stop")) return new Callable() { public Boolean call() throws Exception { + return stop(toks); }}; if (op.equals("status")) return new Callable() { public Boolean call() { return status(toks); -- cgit v1.2.3