tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1125271 - /tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java
Date Fri, 20 May 2011 08:07:54 GMT
Author: antelder
Date: Fri May 20 08:07:54 2011
New Revision: 1125271

URL: http://svn.apache.org/viewvc?rev=1125271&view=rev
Log:
Add an addComposite command to match the Node API and fix the installed command to use the
InstalledContribution instead of the Contribution so that the contribution doesn't need to
be loaded

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=1125271&r1=1125270&r2=1125271&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
Fri May 20 08:07:54 2011
@@ -24,10 +24,13 @@ import static java.lang.System.out;
 
 import java.io.BufferedReader;
 import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
 import java.io.IOException;
 import java.io.InputStreamReader;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
+import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.HashMap;
@@ -35,6 +38,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.concurrent.Callable;
 
+import javax.xml.stream.XMLStreamException;
+
 import org.apache.tuscany.sca.Node;
 import org.apache.tuscany.sca.TuscanyRuntime;
 import org.apache.tuscany.sca.assembly.Binding;
@@ -45,17 +50,12 @@ import org.apache.tuscany.sca.assembly.x
 import org.apache.tuscany.sca.common.java.io.IOHelper;
 import org.apache.tuscany.sca.contribution.Artifact;
 import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.contribution.Export;
-import org.apache.tuscany.sca.contribution.Import;
-import org.apache.tuscany.sca.contribution.java.JavaExport;
-import org.apache.tuscany.sca.contribution.java.JavaImport;
-import org.apache.tuscany.sca.contribution.namespace.NamespaceExport;
-import org.apache.tuscany.sca.contribution.namespace.NamespaceImport;
 import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
 import org.apache.tuscany.sca.impl.NodeImpl;
 import org.apache.tuscany.sca.monitor.ValidationException;
 import org.apache.tuscany.sca.runtime.ActivationException;
 import org.apache.tuscany.sca.runtime.DomainRegistry;
+import org.apache.tuscany.sca.runtime.InstalledContribution;
 import org.apache.tuscany.sca.runtime.Version;
 import org.apache.tuscany.sca.shell.jline.JLine;
 import org.oasisopen.sca.NoSuchServiceException;
@@ -72,7 +72,7 @@ public class Shell {
     private Map<String, Node> standaloneNodes = new HashMap<String, Node>();
     private Map<String, Node> nodes = new HashMap<String, Node>();
 
-    public static final String[] COMMANDS = new String[] {"bye", "domain", "domains", "domainComposite",
"help", "install", "installed", "invoke",
+    public static final String[] COMMANDS = new String[] {"bye", "addComposite", "domain",
"domains", "domainComposite", "help", "install", "installed", "invoke",
                                                           "load", "members", "remove", "run",
"save", "services", "start", "started", "stop"};
 
     public static void main(final String[] args) throws Exception {
@@ -117,6 +117,12 @@ public class Shell {
         }
     }
 
+    boolean addComposite(String curi, String compositeURL) throws ActivationException, ValidationException,
ContributionReadException, FileNotFoundException, XMLStreamException, URISyntaxException {
+        File f = new File(IOHelper.getLocationAsURL(compositeURL).toURI());
+        getNode().addDeploymentComposite(curi, new FileReader(f));
+        return true;
+    }
+
     boolean domain(final String domainURI) {
         if (domainURI.length() < 1) {
             currentDomain = "";
@@ -221,36 +227,37 @@ public class Shell {
         }
         if (toks.size() > 1) {
             String curi = toks.get(1);
-            Contribution c = getNode().getContribution(toks.get(1));
-            if (c == null) {
+            InstalledContribution ic = getNode().getInstalledContribution(toks.get(1));
+            if (ic == null) {
                 out.println("Contribution " + curi + " not installed");
             } else {
                 out.println(curi);
-                out.println("   URL: " + c.getLocation());
+                out.println("   URL: " + ic.getURL());
 
                 List<String> ims = new ArrayList<String>();
-                for (Import im : c.getImports()) {
-                    if (im instanceof JavaImport) {
-                        ims.add(((JavaImport)im).getPackage());
-                    } else if (im instanceof NamespaceImport) {
-                        ims.add(((NamespaceImport)im).getNamespace());
-                    }
+                for (String im : ic.getJavaImports()) {
+                        ims.add(im);
+                }
+                for (String im : ic.getNamespaceImports()) {
+                    ims.add(im);
                 }
                 out.println("   Imports: " + ims);
 
                 List<String> es = new ArrayList<String>();
-                for (Export e : c.getExports()) {
-                    if (e instanceof JavaExport) {
-                        es.add(((JavaExport)e).getPackage());
-                    } else if (e instanceof NamespaceExport) {
-                        es.add(((NamespaceExport)e).getNamespace());
-                    }
+                for (String e : ic.getJavaExports()) {
+                    es.add(e);
+                }
+                for (String e : ic.getNamespaceExports()) {
+                    es.add(e);
                 }
                 out.println("   Exports: " + es);
 
                 List<String> ds = new ArrayList<String>();
-                for (Composite cp : c.getDeployables()) {
-                    ds.add(cp.getURI());
+                for (String cp : ic.getDeployables()) {
+                    ds.add(cp);
+                }
+                for (String cp : ic.getAdditionalDeployables().keySet()) {
+                    ds.add(cp);
                 }
                 out.println("   Deployables: " + ds);
             }
@@ -577,6 +584,12 @@ public class Shell {
     Callable<Boolean> eval(final List<String> toks) {
         final String op = toks.size() > 0 ? toks.get(0) : "";
 
+        if (op.equalsIgnoreCase("addComposite"))
+            return new Callable<Boolean>() {
+                public Boolean call() throws Exception {
+                    return addComposite(toks.get(1), toks.get(2));
+                }
+            };
         if (op.equalsIgnoreCase("domain"))
             return new Callable<Boolean>() {
                 public Boolean call() throws Exception {



Mime
View raw message