From ed33ba727ae79a6a9f9d2be61ffcbad17f857303 Mon Sep 17 00:00:00 2001 From: antelder Date: Wed, 29 Sep 2010 14:27:04 +0000 Subject: Update the Shell with a 'load' command that can load a node from an xml file git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1002652 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/tuscany/sca/shell/Shell.java | 29 +++++++++++++++++++++- .../tuscany/sca/shell/jline/TShellCompletor.java | 1 + 2 files changed, 29 insertions(+), 1 deletion(-) (limited to 'sca-java-2.x/trunk/modules/shell/src') 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 59e98d2c84..7046586828 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 @@ -59,7 +59,7 @@ public class Shell { private Map nodes = new HashMap(); public static final String[] COMMANDS = new String[] {"bye", "domain", "domains", "help", "install", "installed", - "printDomainLevelComposite", "remove", "start", "status", + "load", "printDomainLevelComposite", "remove", "start", "status", "stop"}; public static void main(final String[] args) throws Exception { @@ -189,6 +189,13 @@ public class Shell { return true; } + boolean load(final String configXmlUrl) throws ContributionReadException, ActivationException, ValidationException { + Node node = factory.createNodeFromXML(configXmlUrl); + currentDomain = node.getDomainName(); + nodes.put(currentDomain, node); + return true; + } + boolean printDomainLevelComposite() throws ContributionReadException, ActivationException, ValidationException { out.println("TODO"); // out.println(node.getDomainLevelCompositeAsString()); @@ -377,6 +384,12 @@ public class Shell { return installed(toks); } }; + if (op.equalsIgnoreCase("load")) + return new Callable() { + public Boolean call() throws Exception { + return load(toks.get(1)); + } + }; if (op.equalsIgnoreCase("printDomainLevelComposite")) return new Callable() { public Boolean call() throws Exception { @@ -496,6 +509,8 @@ public class Shell { helpInstall(); } else if ("installed".equalsIgnoreCase(command)) { helpInstalled(); + } else if ("load".equalsIgnoreCase(command)) { + helpLoad(); } else if ("remove".equalsIgnoreCase(command)) { helpRemove(); } else if ("printDomainLevelComposite".equalsIgnoreCase(command)) { @@ -528,6 +543,7 @@ public class Shell { out.println(" domains"); out.println(" install [] [-start -metadata -duris ]"); out.println(" installed []"); + out.println(" load "); out.println(" remove "); out.println(" printDomainLevelComposite"); out.println(" start |"); @@ -603,6 +619,17 @@ public class Shell { out.println(" contributionURI - (optional) the URI of an installed contribution"); } + void helpLoad() { + out.println(" load "); + out.println(); + out.println(" Shows information about the contributions installed on this node,"); + out.println(" including the contribution URI and location along with the URI"); + out.println(" and QName of any composites within the contribution"); + out.println(); + out.println(" Arguments:"); + out.println(" configXmlUrl - (required) the URL of the config file to load"); + } + void helpRemove() { out.println(" remove "); out.println(); diff --git a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/TShellCompletor.java b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/TShellCompletor.java index 64d5613cab..98c609d917 100644 --- a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/TShellCompletor.java +++ b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/TShellCompletor.java @@ -54,6 +54,7 @@ public class TShellCompletor extends ArgumentCompletor { // completors.put("install", new Completor[]{commandCompletor, new InstallCompletor(), new NullCompletor()}); completors.put("install", new Completor[]{commandCompletor, new FileNameCompletor(), new FileNameCompletor(), new NullCompletor()}); completors.put("installed", new Completor[]{commandCompletor, new ICURICompletor(shell), new NullCompletor()}); + completors.put("load", new Completor[]{commandCompletor, new FileNameCompletor(), new NullCompletor()}); completors.put("remove", new Completor[]{commandCompletor, new ICURICompletor(shell), new NullCompletor()}); completors.put("addDeploymentComposite", new Completor[]{commandCompletor, new ICURICompletor(shell), new FileNameCompletor(), new NullCompletor()}); completors.put("printDomainLevelComposite", new Completor[]{commandCompletor, new NullCompletor()}); -- cgit v1.2.3