tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1238666 - in /tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl: RemoteServiceInvocationHandler.java RuntimeUtils.java SCAClientFactoryImpl.java
Date Tue, 31 Jan 2012 15:32:51 GMT
Author: antelder
Date: Tue Jan 31 15:32:51 2012
New Revision: 1238666

URL: http://svn.apache.org/viewvc?rev=1238666&view=rev
Log:
Update sca client to choose an SCA binding endpoint if one is available

Modified:
    tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/RemoteServiceInvocationHandler.java
    tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/RuntimeUtils.java
    tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java

Modified: tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/RemoteServiceInvocationHandler.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/RemoteServiceInvocationHandler.java?rev=1238666&r1=1238665&r2=1238666&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/RemoteServiceInvocationHandler.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/RemoteServiceInvocationHandler.java
Tue Jan 31 15:32:51 2012
@@ -25,7 +25,6 @@ import java.lang.reflect.Proxy;
 import java.net.MalformedURLException;
 import java.net.URL;
 import java.net.URLClassLoader;
-import java.util.List;
 
 import org.apache.tuscany.sca.assembly.AssemblyFactory;
 import org.apache.tuscany.sca.assembly.Component;
@@ -46,8 +45,8 @@ import org.apache.tuscany.sca.interfaced
 import org.apache.tuscany.sca.interfacedef.InvalidInterfaceException;
 import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
 import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
-import org.apache.tuscany.sca.runtime.DomainRegistry;
 import org.apache.tuscany.sca.runtime.ContributionDescription;
+import org.apache.tuscany.sca.runtime.DomainRegistry;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
 import org.apache.tuscany.sca.runtime.RuntimeComponentReference;
 import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
@@ -133,11 +132,7 @@ public class RemoteServiceInvocationHand
 
             CompositeContext compositeContext = new CompositeContext(extensionsRegistry,
domainRegistry, null, domainURI, null, null);
 
-            List<Endpoint> eps = domainRegistry.findEndpoint(serviceName);
-            if (eps == null || eps.size() < 1) {
-                throw new NoSuchServiceException(serviceName);
-            }
-            Endpoint endpoint = eps.get(0); // TODO: what should be done with multiple endpoints?
+            Endpoint endpoint = RuntimeUtils.findEndpoint(domainRegistry, serviceName);
              
             if (serviceInterface == null) {
                 try {

Modified: tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/RuntimeUtils.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/RuntimeUtils.java?rev=1238666&r1=1238665&r2=1238666&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/RuntimeUtils.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/RuntimeUtils.java
Tue Jan 31 15:32:51 2012
@@ -19,8 +19,11 @@
 
 package org.apache.tuscany.sca.client.impl;
 
+import java.util.List;
 import java.util.Properties;
 
+import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.SCABinding;
 import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.core.FactoryExtensionPoint;
@@ -33,6 +36,7 @@ import org.apache.tuscany.sca.runtime.Ex
 import org.apache.tuscany.sca.runtime.RuntimeProperties;
 import org.apache.tuscany.sca.work.WorkScheduler;
 import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
 
 public class RuntimeUtils {
 
@@ -82,4 +86,21 @@ public class RuntimeUtils {
             throw new NoSuchDomainException(domainURI, e);
         }
     }
+    
+    public static Endpoint findEndpoint(DomainRegistry domainRegistry, String serviceName)
throws NoSuchServiceException {
+        List<Endpoint> eps = domainRegistry.findEndpoint(serviceName);
+        if (eps == null || eps.size() < 1) {
+            throw new NoSuchServiceException(serviceName);
+        }
+        
+        // If there is an Endpoint using the SCA binding use that
+        for (Endpoint ep : eps) {
+            if (SCABinding.TYPE.equals(ep.getBinding().getType())) {
+                return ep;
+            }
+        }
+        
+        // Otherwise just choose the first one
+        return eps.get(0);
+    }
 }

Modified: tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java?rev=1238666&r1=1238665&r2=1238666&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/sca-client-impl/src/main/java/org/apache/tuscany/sca/client/impl/SCAClientFactoryImpl.java
Tue Jan 31 15:32:51 2012
@@ -24,7 +24,6 @@ import java.lang.reflect.Proxy;
 import java.net.URI;
 import java.security.AccessController;
 import java.security.PrivilegedAction;
-import java.util.List;
 
 import org.apache.tuscany.sca.assembly.Endpoint;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
@@ -89,11 +88,7 @@ public class SCAClientFactoryImpl extend
         
         // The service is a component in a local runtime
         if (!remoteClient) {
-            List<Endpoint> endpoints = domainRegistry.findEndpoint(serviceURI);
-            if (endpoints.size() < 1) {
-                throw new NoSuchServiceException(serviceURI);
-            }
-            Endpoint ep = endpoints.get(0);
+            Endpoint ep = RuntimeUtils.findEndpoint(domainRegistry, serviceURI);
             if (((RuntimeComponent)ep.getComponent()).getComponentContext() != null) {
                 return ((RuntimeComponent)ep.getComponent()).getServiceReference(serviceInterface,
serviceName).getService();
             }



Mime
View raw message