From 27e3cec43d8effa06ba8710907e416539b332096 Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Wed, 8 Sep 2010 00:02:05 +0000 Subject: Change uri parameter to location of deployment composite and make it optional. Change restart command to use previous config if not specified. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@993561 13f79535-47bb-0310-9956-ffa450edef68 --- .../samples/launcher-shell/scripts/test-remote.txt | 20 +++++----- .../samples/launcher-shell/scripts/test-start.txt | 2 +- .../shell/samples/launcher-shell/scripts/test.txt | 20 +++++----- .../launcher-shell/src/main/java/sample/Shell.java | 44 ++++++++++++---------- 4 files changed, 46 insertions(+), 40 deletions(-) diff --git a/sandbox/sebastien/java/shell/samples/launcher-shell/scripts/test-remote.txt b/sandbox/sebastien/java/shell/samples/launcher-shell/scripts/test-remote.txt index fd7bd5766a..c94e6eb9bb 100644 --- a/sandbox/sebastien/java/shell/samples/launcher-shell/scripts/test-remote.txt +++ b/sandbox/sebastien/java/shell/samples/launcher-shell/scripts/test-remote.txt @@ -14,23 +14,23 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations -start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar +start foo http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar stop foo -start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar +start foo http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar stop foo -start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar +start foo http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar stop foo -start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar +start foo http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar stop foo -start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar +start foo http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar stop foo -start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar +start foo http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar stop foo -start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar +start foo http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar stop foo -start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar +start foo http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar stop foo -start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar +start foo http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar stop foo -start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar +start foo http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar stop foo diff --git a/sandbox/sebastien/java/shell/samples/launcher-shell/scripts/test-start.txt b/sandbox/sebastien/java/shell/samples/launcher-shell/scripts/test-start.txt index 71f7f3f4aa..69ac172adf 100644 --- a/sandbox/sebastien/java/shell/samples/launcher-shell/scripts/test-start.txt +++ b/sandbox/sebastien/java/shell/samples/launcher-shell/scripts/test-start.txt @@ -14,5 +14,5 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations -start foo c1 http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar +start foo http://people.apache.org/~jsdelfino/tuscany/java/test/sample-contribution-binding-ws-calculator.jar status diff --git a/sandbox/sebastien/java/shell/samples/launcher-shell/scripts/test.txt b/sandbox/sebastien/java/shell/samples/launcher-shell/scripts/test.txt index 66c760b937..92a03492c7 100644 --- a/sandbox/sebastien/java/shell/samples/launcher-shell/scripts/test.txt +++ b/sandbox/sebastien/java/shell/samples/launcher-shell/scripts/test.txt @@ -14,23 +14,23 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations -start foo c1 ../contribution-implementation-java-calculator/target/classes +start foo ../contribution-implementation-java-calculator/target/classes stop foo -start foo c1 ../contribution-implementation-java-calculator/target/classes +start foo ../contribution-implementation-java-calculator/target/classes stop foo -start foo c1 ../contribution-implementation-java-calculator/target/classes +start foo ../contribution-implementation-java-calculator/target/classes stop foo -start foo c1 ../contribution-implementation-java-calculator/target/classes +start foo ../contribution-implementation-java-calculator/target/classes stop foo -start foo c1 ../contribution-implementation-java-calculator/target/classes +start foo ../contribution-implementation-java-calculator/target/classes stop foo -start foo c1 ../contribution-implementation-java-calculator/target/classes +start foo ../contribution-implementation-java-calculator/target/classes stop foo -start foo c1 ../contribution-implementation-java-calculator/target/classes +start foo ../contribution-implementation-java-calculator/target/classes stop foo -start foo c1 ../contribution-implementation-java-calculator/target/classes +start foo ../contribution-implementation-java-calculator/target/classes stop foo -start foo c1 ../contribution-implementation-java-calculator/target/classes +start foo ../contribution-implementation-java-calculator/target/classes stop foo -start foo c1 ../contribution-implementation-java-calculator/target/classes +start foo ../contribution-implementation-java-calculator/target/classes stop foo diff --git a/sandbox/sebastien/java/shell/samples/launcher-shell/src/main/java/sample/Shell.java b/sandbox/sebastien/java/shell/samples/launcher-shell/src/main/java/sample/Shell.java index f2790409e9..d0d8fb5dfe 100644 --- a/sandbox/sebastien/java/shell/samples/launcher-shell/src/main/java/sample/Shell.java +++ b/sandbox/sebastien/java/shell/samples/launcher-shell/src/main/java/sample/Shell.java @@ -44,44 +44,44 @@ import org.apache.tuscany.sca.node.NodeFactory; * A little SCA command shell. */ public class Shell { - final NodeFactory nodeFactory; + final NodeFactory nf; - public static class NodeInfo { + public static class Nodeconf { final String name; - final String curi; final String cloc; + final String dcuri; final Node node; - NodeInfo(final String name, final String curi, final String cloc, final Node node) { + Nodeconf(final String name, final String cloc, final String dcuri, final Node node) { this.name = name; - this.curi = curi; this.cloc = cloc; + this.dcuri = dcuri; this.node = node; } public String toString() { - return name + " " + curi + " " + cloc; + return name + " " + cloc + (dcuri != null? " " + dcuri : ""); } } - final Map nodes = new HashMap(); + final Map nodes = new HashMap(); final List history = new ArrayList(); public Shell(NodeFactory nf) { - this.nodeFactory = nf; + this.nf = nf; } - List start(final String name, final String curi, final String cloc) { + List start(final String name, final String cloc, final String dcuri) { if(nodes.containsKey(name)) return emptyList(); - final Node node = nodeFactory.createNode(new Contribution(curi, cloc)); - nodes.put(name, new NodeInfo(name, curi, cloc, node)); + final Node node = dcuri != null? nf.createNode(dcuri, new Contribution(cloc, cloc)) : nf.createNode(new Contribution(cloc, cloc)); + nodes.put(name, new Nodeconf(name, cloc, dcuri, node)); node.start(); return emptyList(); } List stop(final String name) { - final NodeInfo ninfo = nodes.get(name); + final Nodeconf ninfo = nodes.get(name); if(ninfo == null) return emptyList(); ninfo.node.stop(); @@ -90,15 +90,21 @@ public class Shell { } List stop() { - for(NodeInfo ninfo: nodes.values()) + for(Nodeconf ninfo: nodes.values()) ninfo.node.stop(); nodes.clear(); return emptyList(); } - List restart(final String name, final String curi, final String cloc) { - stop(name); - return start(name, curi, cloc); + List restart(final String name, final String cloc, final String dcuri) { + final Nodeconf ninfo = nodes.get(name); + if(ninfo == null) + return start(name, cloc, dcuri); + ninfo.node.stop(); + nodes.remove(name); + if (cloc == null) + return start(ninfo.name, ninfo.cloc, ninfo.dcuri); + return start(name, cloc, dcuri); } List status() { @@ -124,7 +130,7 @@ public class Shell { if(op.equals("start")) return new Callable>() { public List call() { - return start(toks.get(1), toks.get(2), toks.get(3)); + return start(toks.get(1), toks.get(2), toks.size() >= 4? toks.get(3) : null); } }; if(op.equals("stop")) @@ -138,7 +144,7 @@ public class Shell { if(op.equals("restart")) return new Callable>() { public List call() { - return restart(toks.get(1), toks.get(2), toks.get(3)); + return restart(toks.get(1), toks.size() >= 3? toks.get(2) : null, toks.size() >= 4? toks.get(3) : null); } }; if(op.equals("status")) @@ -184,7 +190,7 @@ public class Shell { return true; } - public Map run(final BufferedReader r, final PrintWriter w) throws IOException { + public Map run(final BufferedReader r, final PrintWriter w) throws IOException { while(print(apply(eval(read(r))), w)) ; r.close(); -- cgit v1.2.3