diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-20 08:07:54 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-20 08:07:54 +0000 |
commit | c34f78773a7696a06db1851389f292485e0e7ac9 (patch) | |
tree | 3804bac359ba24421b1e5590397181d7f7979c82 /sca-java-2.x/trunk/modules/shell/src/main | |
parent | c2ae99f1e72da5a4dcfa2e2f812b6e06064b564d (diff) |
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
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1125271 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/shell/src/main')
-rw-r--r-- | sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/Shell.java | 61 |
1 files changed, 37 insertions, 24 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 d5b2e6ee44..5fccf32c49 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 @@ -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.xml.Utils; 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 {
|