summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2012-05-01 08:16:40 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2012-05-01 08:16:40 +0000
commitef40d3b0b39917441426516d59ecab859e3428fc (patch)
tree376400b29927442e36e9a02d2860919c1976a20c
parentfaa4500506113c301c163a740d2217e1c6b93f72 (diff)
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
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java43
1 files changed, 33 insertions, 10 deletions
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;