Author: antelder
Date: Tue Jun  7 12:37:13 2011
New Revision: 1132974

URL: http://svn.apache.org/viewvc?rev=1132974&view=rev
Log:
Fix NPE with remote services by simplify code to just use node.getService to 
get the proxy

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

Modified: 
tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/ServiceOperationCompletor.java
URL: 
http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/ServiceOperationCompletor.java?rev=1132974&r1=1132973&r2=1132974&view=diff
==============================================================================
--- 
tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/ServiceOperationCompletor.java
 (original)
+++ 
tuscany/sca-java-2.x/trunk/modules/shell/src/main/java/org/apache/tuscany/sca/shell/jline/ServiceOperationCompletor.java
 Tue Jun  7 12:37:13 2011
@@ -31,6 +31,7 @@ import org.apache.tuscany.sca.impl.NodeI
 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 e
     @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);
     }
 }


Reply via email to