summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/shell/src/main
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-07-04 11:25:24 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2010-07-04 11:25:24 +0000
commite43e3fa3370df3e8b5bc8b6d6d2e5cf8ab5f903f (patch)
treec129d0358022fa8a89ff5f7340d1ed87cba86bfb /sca-java-2.x/trunk/modules/shell/src/main
parenta33dbd3ca68717debdbeba860f58761bf440ae10 (diff)
Use a nicer default contribution uri
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@960321 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.java27
1 files changed, 25 insertions, 2 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 2a5dd5ff2d..0b3f5c910f 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
@@ -23,6 +23,7 @@ import static java.lang.System.in;
import static java.lang.System.out;
import java.io.BufferedReader;
+import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.StringReader;
@@ -69,13 +70,35 @@ public class Shell {
}
boolean install(final String cloc) throws ContributionReadException, ActivationException, ValidationException {
- node.installContribution(cloc, cloc, null, null, true);
+ String uri = getURI(cloc);
+ node.installContribution(getURI(cloc), cloc, null, null, true);
+ out.println("installed: " + uri);
return true;
}
+ private String getURI(String contributionURL) {
+ int lastDot = contributionURL.lastIndexOf('.');
+ int lastSep = contributionURL.lastIndexOf("/");
+ String uri = contributionURL;
+ if (lastDot > -1 && lastSep > -1 && lastDot > lastSep) {
+ uri = contributionURL.substring(lastSep+1, lastDot);
+ } else {
+ try {
+ File f = new File(contributionURL);
+ if ("classes".equals(f.getName())) {
+ uri = f.getParentFile().getParentFile().getName();
+ }
+ } catch (Exception e) {
+ // ignore
+ }
+ }
+ return uri;
+ }
+
boolean listDeployedCompostes(String curi) throws ContributionReadException, ActivationException, ValidationException {
for (String uri : node.getDeployedCompostes(curi)) {
- out.println(uri.substring(curi.length()+1));
+// out.println(uri.substring(curi.length()+1));
+ out.println(uri);
}
return true;
}