You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sl...@apache.org on 2011/08/04 10:54:08 UTC

svn commit: r1153789 - /tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java

Author: slaws
Date: Thu Aug  4 08:54:07 2011
New Revision: 1153789

URL: http://svn.apache.org/viewvc?rev=1153789&view=rev
Log:
TUSCANY-3904 - Apply Greg's patch so that the correct endpoint is picked up when SCAClientFactory.getService() references a promoted service. 

Modified:
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java?rev=1153789&r1=1153788&r2=1153789&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeComponentImpl.java Thu Aug  4 08:54:07 2011
@@ -118,41 +118,14 @@ public class RuntimeComponentImpl extend
     public <B> ServiceReference<B> getServiceReference(Class<B> businessInterface, String serviceName) {
         RuntimeComponentContext componentContext = null;
 
-        // If the component is a composite, then we need to find the
-        // non-composite component that provides the requested service
-        if (getImplementation() instanceof Composite) {
-            for (ComponentService componentService : getServices()) {
-                String bindingName = null;
-                if (serviceName != null) {
-                    int index = serviceName.indexOf('/');
-                    if (index != -1) {
-                        bindingName = serviceName.substring(index + 1);
-                        serviceName = serviceName.substring(0, index);
-                    }
-                }
-                if (serviceName == null || serviceName.equals(componentService.getName())) {
-                    CompositeService compositeService = (CompositeService)componentService.getService();
-                    if (compositeService != null) {
-                        componentContext =
-                            ((RuntimeComponent)compositeService.getPromotedComponent()).getComponentContext();
-                        serviceName = compositeService.getPromotedService().getName();
-                        if (bindingName != null) {
-                            serviceName = serviceName + "/" + bindingName;
-                        }
-                        return componentContext.createSelfReference(businessInterface, serviceName);
-                    }
-                    break;
-                }
-            }
-            // No matching service found
-            throw new ServiceRuntimeException("Composite service not found: " + serviceName);
+        // TUSCANY-3904 Removed implementation.composite path
+
+        componentContext = getComponentContext();
+        if (serviceName != null) {
+            return componentContext.createSelfReference(businessInterface, serviceName);
         } else {
-            componentContext = getComponentContext();
-            if (serviceName != null) {
-                return componentContext.createSelfReference(businessInterface, serviceName);
-            } else {
-                return componentContext.createSelfReference(businessInterface);
-            }
+            return componentContext.createSelfReference(businessInterface);
         }
+
     }
 }