From ef40d3b0b39917441426516d59ecab859e3428fc Mon Sep 17 00:00:00 2001 From: antelder Date: Tue, 1 May 2012 08:16:40 +0000 Subject: Update Shell to support starting from a node xml file git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1332566 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/tuscany/sca/shell/Shell.java | 43 +++++++++++++++++----- 1 file changed, 33 insertions(+), 10 deletions(-) (limited to 'sca-java-2.x/trunk/modules') 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 046302e9cf..c1231cf13a 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 @@ -26,6 +26,7 @@ import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.io.InputStreamReader; +import java.net.MalformedURLException; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -76,11 +77,14 @@ public class Shell { boolean showHelp = false; String contribution = null; + String nodeXML = null; for (String s : args) { if ("-nojline".equals(s)) { useJline = false; } else if ("-help".equals(s)) { showHelp = true; + } else if (s.startsWith("-nodeXML:")) { + nodeXML = s.substring("-nodeXML:".length()); } else { if (s.startsWith("uri:") || s.startsWith("properties:")) { domainURI = s; @@ -89,21 +93,40 @@ public class Shell { } } } - Shell shell = new Shell(domainURI, useJline); - if (showHelp || contribution==null) { - shell.help(null); - } - if (contribution != null) { - System.out.println(); - System.out.println("install " + contribution + " -start"); - String curi = shell.getNode().installContribution(contribution); - shell.getNode().startDeployables(curi); + Shell shell; + if (nodeXML != null) { + shell = new Shell(new File(nodeXML), useJline); + } else { + shell = new Shell(domainURI, useJline); + if (showHelp || contribution==null) { + shell.help(null); + } + if (contribution != null) { + System.out.println(); + System.out.println("install " + contribution + " -start"); + String curi = shell.getNode().installContribution(contribution); + shell.getNode().startDeployables(curi); + } } - shell.run(); } + public Shell(File nodeXML, boolean useJLine) throws ContributionReadException, MalformedURLException, ActivationException, ValidationException { + this.runtime = TuscanyRuntime.newInstance(); + this.useJline = useJLine; + + try { + initCommands(); + } catch (IOException e) { + throw new RuntimeException(e); + } + + Node node = runtime.createNodeFromXML(nodeXML.toURI().toURL().toString()); + currentDomain = node.getDomainName(); + nodes.put(currentDomain, node); + } + public Shell(String domainURI, boolean useJLine) { this.runtime = TuscanyRuntime.newInstance(); this.useJline = useJLine; -- cgit v1.2.3