You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by an...@apache.org on 2012/05/01 10:16:40 UTC

svn commit: r1332566 - /tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java

Author: antelder
Date: Tue May  1 08:16:40 2012
New Revision: 1332566

URL: http://svn.apache.org/viewvc?rev=1332566&view=rev
Log:
Update Shell to support starting from a node xml file

Modified:
    tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java

Modified: tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java?rev=1332566&r1=1332565&r2=1332566&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java Tue May  1 08:16:40 2012
@@ -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;