summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/shell/src/main
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-06-07 12:37:13 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-06-07 12:37:13 +0000
commit13a270ec9090ca98e293fca62120f659aec0c834 (patch)
tree674216ef8f6e955a871af0ec06f9544ca76b1d7a /sca-java-2.x/trunk/modules/shell/src/main
parentf415915d6da3a5d5543b9dbef2f3319311d1c053 (diff)
Fix NPE with remote services by simplify code to just use node.getService to get the proxy
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1132974 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/jline/ServiceOperationCompletor.java43
1 files changed, 24 insertions, 19 deletions
diff --git a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/ServiceOperationCompletor.java b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/ServiceOperationCompletor.java
index 3525bacdee..c61e8cf4ca 100644
--- a/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/ServiceOperationCompletor.java
+++ b/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/ServiceOperationCompletor.java
@@ -31,6 +31,7 @@ import org.apache.tuscany.sca.impl.NodeImpl;
import org.apache.tuscany.sca.runtime.DomainRegistry;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
import org.apache.tuscany.sca.shell.Shell;
+import org.oasisopen.sca.NoSuchServiceException;
/**
* A Completor for available service operations
@@ -58,27 +59,31 @@ public class ServiceOperationCompletor extends SimpleCompletor {
@Override
public int complete(final String buffer, final int cursor, final List clist) {
String service = TShellCompletor.lastArg;
- DomainRegistry reg = ((NodeImpl)shell.getNode()).getEndpointRegistry();
- List<Endpoint> endpoints = reg.findEndpoint(service);
- if (endpoints.size() < 1) {
- return -1;
- }
- String serviceName = null;
- if (service.contains("/")) {
- int i = service.indexOf("/");
- if (i < service.length()-1) {
- serviceName = service.substring(i+1);
- }
- }
- Object proxy = ((RuntimeComponent)endpoints.get(0).getComponent()).getServiceReference(null, serviceName).getService();
- Method[] ms = proxy.getClass().getMethods();
- List<String> ops = new ArrayList<String>();
- for (Method m : ms) {
- if (!EXCLUDED_OPS.contains(m.getName())) {
- ops.add(m.getName());
+// DomainRegistry reg = ((NodeImpl)shell.getNode()).getEndpointRegistry();
+// List<Endpoint> endpoints = reg.findEndpoint(service);
+// if (endpoints.size() < 1) {
+// return -1;
+// }
+// String serviceName = null;
+// if (service.contains("/")) {
+// int i = service.indexOf("/");
+// if (i < service.length()-1) {
+// serviceName = service.substring(i+1);
+// }
+// }
+// Object proxy = ((RuntimeComponent)endpoints.get(0).getComponent()).getServiceReference(null, serviceName).getService();
+ try {
+ Object proxy = shell.getNode().getService(null, service);
+ Method[] ms = proxy.getClass().getMethods();
+ List<String> ops = new ArrayList<String>();
+ for (Method m : ms) {
+ if (!EXCLUDED_OPS.contains(m.getName())) {
+ ops.add(m.getName());
+ }
}
+ setCandidateStrings(ops.toArray(new String[ops.size()]));
+ } catch (NoSuchServiceException e) {
}
- setCandidateStrings(ops.toArray(new String[ops.size()]));
return super.complete(buffer, cursor, clist);
}
}