You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2010/02/26 00:00:57 UTC

svn commit: r916483 - in /tuscany/sca-java-2.x/trunk: itest/nodes/ itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/ modules/assembly/src/main/java/...

Author: rfeng
Date: Thu Feb 25 23:00:57 2010
New Revision: 916483

URL: http://svn.apache.org/viewvc?rev=916483&view=rev
Log:
Add the check for local-by-reference, local-by-value and remote invocations for binding.sca

Modified:
    tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java
    tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java
    tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java
    tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java
    tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java
    tuscany/sca-java-2.x/trunk/itest/nodes/pom.xml
    tuscany/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java
    tuscany/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
    tuscany/sca-java-2.x/trunk/modules/binding-http-runtime/META-INF/MANIFEST.MF
    tuscany/sca-java-2.x/trunk/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java
    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java
    tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java
    tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java
    tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java

Modified: tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java Thu Feb 25 23:00:57 2010
@@ -26,7 +26,7 @@
 import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
 import org.junit.Assert;
 import org.junit.Test;
-import org.oasisopen.sca.SCARuntimeException;
+import org.oasisopen.sca.ServiceRuntimeException;
 
 /**
  * Test binding.sca in the same classloader
@@ -49,10 +49,13 @@
         Node node2 = createServiceNode(factory1);
         node1.start();
         node2.start();
-        runClient(node1);
-        node2.stop();
-        node1.stop();
-        factory1.destroy();
+        try {
+            runClient(node1);
+        } finally {
+            node2.stop();
+            node1.stop();
+            factory1.destroy();
+        }
     }
 
     /**
@@ -94,14 +97,15 @@
         node2.start();
         try {
             runClient(node1);
-            Assert.fail("SCARuntimeException should have been thrown.");
-        } catch (SCARuntimeException e) {
+            Assert.fail("ServiceRuntimeException should have been thrown.");
+        } catch (ServiceRuntimeException e) {
             // ignore
+        } finally {
+            node2.stop();
+            node1.stop();
+            factory2.destroy();
+            factory1.destroy();
         }
-        node2.stop();
-        node1.stop();
-        factory2.destroy();
-        factory1.destroy();
     }
 
     /**
@@ -117,7 +121,7 @@
         String id = client.create("Ray");
         Assert.assertEquals("Ray", client.getName(id));
     }
-    
+
     /**
      * One node factory and one node for both composites
      */
@@ -130,9 +134,12 @@
 
         Node node1 = factory.createNode(config1);
         node1.start();
-        runClient(node1);
-        node1.stop();
-        factory.destroy();
+        try {
+            runClient(node1);
+        } finally {
+            node1.stop();
+            factory.destroy();
+        }
     }
 
 }

Modified: tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java Thu Feb 25 23:00:57 2010
@@ -31,12 +31,13 @@
 public class ClientNodeSharedCustomerTestCase {
     private static Node clientNode;
     private static TestCaseRunner runner;
+    private static NodeFactory factory;
 
     @BeforeClass
     public static void setUpBeforeClass() throws Exception {
         runner = new TestCaseRunner(ServiceNode.class, Remote.class.getName(), RemoteServiceImpl.class.getName());
         runner.beforeClass();
-        NodeFactory factory = NodeFactory.getInstance();
+        factory = NodeFactory.getInstance();
         clientNode = BindingSCATestCase.createClientNode(factory).start();
         Thread.sleep(1000);
     }
@@ -54,5 +55,8 @@
         if (runner != null) {
             runner.afterClass();
         }
+        if (factory != null) {
+            factory.destroy();
+        }
     }
 }

Modified: tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java Thu Feb 25 23:00:57 2010
@@ -57,5 +57,6 @@
         if (runner != null) {
             runner.afterClass();
         }
+        NodeFactory.getInstance().destroy();
     }
 }

Modified: tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java Thu Feb 25 23:00:57 2010
@@ -19,6 +19,7 @@
 
 package org.apache.tuscany.sca.itest.bindingsca;
 
+import org.apache.tuscany.sca.node.NodeFactory;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -48,5 +49,6 @@
         if (runner != null) {
             runner.afterClass();
         }
+        NodeFactory.getInstance().destroy();
     }
 }

Modified: tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java Thu Feb 25 23:00:57 2010
@@ -19,6 +19,7 @@
 
 package org.apache.tuscany.sca.itest.bindingsca;
 
+import org.apache.tuscany.sca.node.NodeFactory;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -51,5 +52,6 @@
         if (runner != null) {
             runner.afterClass();
         }
+        NodeFactory.getInstance().destroy();
     }
 }

Modified: tuscany/sca-java-2.x/trunk/itest/nodes/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/itest/nodes/pom.xml?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/itest/nodes/pom.xml (original)
+++ tuscany/sca-java-2.x/trunk/itest/nodes/pom.xml Thu Feb 25 23:00:57 2010
@@ -47,6 +47,7 @@
     <module>one-jvm-hazelcast</module>
     <module>one-jvm-hazelcast-client</module>
     <module>one-jvm-tribes</module>
+    <module>binding-sca-tribes</module>
     <module>one-node-test</module>
     <module>two-nodes-test</module>
     <module>two-nodes-two-vms-test</module>

Modified: tuscany/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java Thu Feb 25 23:00:57 2010
@@ -78,15 +78,21 @@
      * Simply speaking, any request from the source operation can be processed by the target operation and
      * the normal response or fault/exception from the target operation can be handled by the source operation.
      * 
-     * Please note this compatibility check is NOT symmetric.  
+     * Please note this compatibility check is NOT symmetric. But the following should be guaranteed:
+     * <ul>
+     * <li>(source, target, SUB) == (target, source, SUPER)
+     * <li>(source, target, MUTUAL) == (source, target, SUB) && (target, source, SUB) == (source, target, SUPER) && (source, target, SUPER)
      * 
      * @param source The source operation
      * @param target The target operation
-     * @param compatibilityType TODO
+     * @param compatibilityType The type of compatibility
      * @return true if the source operation is compatible with the target
      *         operation
      */
     boolean isCompatible(Operation source, Operation target, Compatibility compatibilityType);
+    
+    boolean isCompatibleByReference(Operation source, Operation target, Compatibility compatibilityType);
+    boolean isCompatibleByValue(Operation source, Operation target, Compatibility compatibilityType);
 
     /**
      * An interface A is a Compatible Subset of a second interface B if and only if all of points 1 through 6 

Modified: tuscany/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java Thu Feb 25 23:00:57 2010
@@ -116,6 +116,10 @@
     } // end method isEqual
 
     public boolean isCompatible(Operation source, Operation target, Compatibility compatibilityType) {
+        return isCompatible(source, target, compatibilityType, true);
+    }
+
+    public boolean isCompatible(Operation source, Operation target, Compatibility compatibilityType, boolean byValue) {
         if (source == target) {
             return true;
         }
@@ -133,7 +137,7 @@
             return false;
         }
 
-        boolean remotable = source.getInterface().isRemotable();
+        boolean passByValue = (source.getInterface().isRemotable()) && byValue;
 
         //        if (source.getInterface().isRemotable()) {
         //            return true;
@@ -164,7 +168,7 @@
             return true;
         }
 
-        if (!isCompatible(targetOutputType, sourceOutputType, remotable)) {
+        if (!isCompatible(targetOutputType, sourceOutputType, passByValue)) {
             return false;
         }
 
@@ -174,7 +178,7 @@
 
         int size = sourceInputType.size();
         for (int i = 0; i < size; i++) {
-            if (!isCompatible(sourceInputType.get(i), targetInputType.get(i), remotable)) {
+            if (!isCompatible(sourceInputType.get(i), targetInputType.get(i), passByValue)) {
                 return false;
             }
         }
@@ -186,7 +190,7 @@
             boolean found = true;
             for (DataType sourceFaultType : source.getFaultTypes()) {
                 found = false;
-                if (isCompatible(targetFaultType, sourceFaultType, remotable)) {
+                if (isCompatible(targetFaultType, sourceFaultType, passByValue)) {
                     // Target fault type can be covered by the source fault type
                     found = true;
                     break;
@@ -198,6 +202,13 @@
         }
 
         return true;
+    }    
+    public boolean isCompatibleByReference(Operation source, Operation target, Compatibility compatibilityType) {
+        return isCompatible(source, target, compatibilityType, false);
+    }
+
+    public boolean isCompatibleByValue(Operation source, Operation target, Compatibility compatibilityType) {
+        return isCompatible(source, target, compatibilityType, true);
     }
 
     // FIXME: How to improve the performance for the lookup

Modified: tuscany/sca-java-2.x/trunk/modules/binding-http-runtime/META-INF/MANIFEST.MF
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-http-runtime/META-INF/MANIFEST.MF?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-http-runtime/META-INF/MANIFEST.MF (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-http-runtime/META-INF/MANIFEST.MF Thu Feb 25 23:00:57 2010
@@ -12,6 +12,7 @@
  javax.servlet.http,
  org.apache.tuscany.sca.assembly;version="2.0.0",
  org.apache.tuscany.sca.binding.http;version="2.0.0",
+ org.apache.tuscany.sca.common.http;version="2.0.0",
  org.apache.tuscany.sca.core;version="2.0.0",
  org.apache.tuscany.sca.host.http;version="2.0.0",
  org.apache.tuscany.sca.interfacedef;version="2.0.0",

Modified: tuscany/sca-java-2.x/trunk/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java Thu Feb 25 23:00:57 2010
@@ -34,6 +34,7 @@
 import org.apache.tuscany.sca.interfacedef.Operation;
 import org.apache.tuscany.sca.invocation.Invoker;
 import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.EndpointReferenceProvider;
 import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
 import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -45,7 +46,7 @@
  * binding-ws-axis implementation for sending messages to remote services so this provider
  * uses the ws-axis provider under the covers. 
  */
-public class Axis2SCAReferenceBindingProvider implements ReferenceBindingProvider {
+public class Axis2SCAReferenceBindingProvider implements EndpointReferenceProvider {
 
     private static final Logger logger = Logger.getLogger(Axis2SCAReferenceBindingProvider.class.getName());
     
@@ -116,4 +117,10 @@
     public void stop() {
         axisReferenceBindingProvider.stop();
     }
+
+    public void configure() {
+        if (axisReferenceBindingProvider instanceof EndpointReferenceProvider) {
+            ((EndpointReferenceProvider)axisReferenceBindingProvider).configure();
+        }
+    }
 }

Modified: tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java Thu Feb 25 23:00:57 2010
@@ -29,11 +29,14 @@
 import org.apache.tuscany.sca.core.FactoryExtensionPoint;
 import org.apache.tuscany.sca.core.UtilityExtensionPoint;
 import org.apache.tuscany.sca.databinding.Mediator;
+import org.apache.tuscany.sca.interfacedef.Compatibility;
 import org.apache.tuscany.sca.interfacedef.InterfaceContract;
+import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
 import org.apache.tuscany.sca.interfacedef.Operation;
 import org.apache.tuscany.sca.invocation.InvocationChain;
 import org.apache.tuscany.sca.invocation.Invoker;
 import org.apache.tuscany.sca.provider.BindingProviderFactory;
+import org.apache.tuscany.sca.provider.EndpointReferenceProvider;
 import org.apache.tuscany.sca.provider.ProviderFactoryExtensionPoint;
 import org.apache.tuscany.sca.provider.ReferenceBindingProvider;
 import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -41,6 +44,7 @@
 import org.apache.tuscany.sca.runtime.RuntimeComponentService;
 import org.apache.tuscany.sca.runtime.RuntimeEndpoint;
 import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
+import org.oasisopen.sca.ServiceRuntimeException;
 import org.oasisopen.sca.ServiceUnavailableException;
 
 /**
@@ -52,7 +56,7 @@
  *
  * @version $Rev$ $Date$
  */
-public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvider {
+public class RuntimeSCAReferenceBindingProvider implements EndpointReferenceProvider {
 
     private static final Logger logger = Logger.getLogger(RuntimeSCAReferenceBindingProvider.class.getName());
 
@@ -66,6 +70,7 @@
     private ReferenceBindingProvider distributedProvider = null;
     private SCABindingFactory scaBindingFactory;
     private Mediator mediator;
+    private InterfaceContractMapper interfaceContractMapper;
 
     public RuntimeSCAReferenceBindingProvider(ExtensionPointRegistry extensionPoints,
                                               RuntimeEndpointReference endpointReference) {
@@ -85,10 +90,14 @@
             (BindingProviderFactory<DistributedSCABinding>)factoryExtensionPoint
                 .getProviderFactory(DistributedSCABinding.class);
 
-        this.mediator = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class).getUtility(Mediator.class);
+        UtilityExtensionPoint utilities = extensionPoints.getExtensionPoint(UtilityExtensionPoint.class);
+        this.mediator = utilities.getUtility(Mediator.class);
+        this.interfaceContractMapper = utilities.getUtility(InterfaceContractMapper.class);
     }
 
     public boolean isTargetRemote() {
+        return endpointReference.getTargetEndpoint().isRemote();
+        /*
         boolean targetIsRemote = false;
 
         // The decision is based on the results of the wiring process in the assembly model
@@ -119,6 +128,7 @@
         	targetIsRemote = false;
         }
         return targetIsRemote;
+        */
     }
 
     private ReferenceBindingProvider getDistributedProvider() {
@@ -127,14 +137,14 @@
             // initialize the remote provider if it hasn't been done already
             if (distributedProvider == null) {
                 if (reference.getInterfaceContract() != null && !reference.getInterfaceContract().getInterface().isRemotable()) {
-                    throw new IllegalStateException("Reference interface not remotable for component: " + component
+                    throw new ServiceRuntimeException("Reference interface not remotable for component: " + component
                         .getName()
                         + " and reference: "
                         + reference.getName());
                 }
 
                 if (distributedProviderFactory == null) {
-                    throw new IllegalStateException("No distributed SCA binding available for component: " + component
+                    throw new ServiceRuntimeException("No distributed SCA binding available for component: " + component
                         .getName()
                         + " and reference: "
                         + reference.getName());
@@ -182,6 +192,7 @@
             return false;
         }
     }
+   
 
     private Invoker getInvoker(RuntimeEndpointReference epr, Operation operation) {
         Endpoint target = epr.getTargetEndpoint();
@@ -190,10 +201,24 @@
             if (service != null) { // not a callback wire
                 InvocationChain chain = ((RuntimeEndpoint) target).getInvocationChain(operation);
                 
+                boolean passByValue = false;
+                Operation targetOp = chain.getTargetOperation();
+                if (!operation.getInterface().isRemotable()) {
+                    if (interfaceContractMapper.isCompatibleByReference(operation, targetOp, Compatibility.SUBSET)) {
+                       passByValue = false;
+                    }
+                } else {
+                    boolean allowsPBR = chain.allowsPassByReference();
+                    if (allowsPBR && interfaceContractMapper.isCompatibleByReference(operation, targetOp, Compatibility.SUBSET)) {
+                        passByValue = false;
+                    } else if (interfaceContractMapper.isCompatibleByValue(operation, targetOp, Compatibility.SUBSET)) {
+                        passByValue = true;
+                    }
+                }
                 // it turns out that the chain source and target operations are the same, and are the operation 
                 // from the target, not sure if thats by design or a bug. The SCA binding invoker needs to know 
                 // the source and target class loaders so pass in the real source operation in the constructor 
-                return chain == null ? null : new SCABindingInvoker(chain, operation, mediator);
+                return chain == null ? null : new SCABindingInvoker(chain, operation, mediator, passByValue);
             }
         }
         return null;
@@ -221,25 +246,32 @@
     public void start() {
         if (started) {
             return;
-        } else {
-            started = true;
-        }
-
+        } 
         if (getDistributedProvider() != null) {
             distributedProvider.start();
         }
+        started = true;
     }
 
     public void stop() {
         if (!started) {
             return;
-        } else {
+        } 
+
+        try {
+            if (getDistributedProvider() != null) {
+                distributedProvider.stop();
+            }
+        } finally {
             started = false;
         }
+    }
 
-        if (getDistributedProvider() != null) {
-            distributedProvider.stop();
+    public void configure() {
+        if (distributedProvider instanceof EndpointReferenceProvider) {
+            ((EndpointReferenceProvider)distributedProvider).configure();
         }
+
     }
 
 }

Modified: tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java Thu Feb 25 23:00:57 2010
@@ -26,6 +26,7 @@
 import org.apache.tuscany.sca.invocation.InvocationChain;
 import org.apache.tuscany.sca.invocation.Invoker;
 import org.apache.tuscany.sca.invocation.Message;
+import org.apache.tuscany.sca.invocation.Phase;
 
 /**
  * @version $Rev$ $Date$
@@ -35,25 +36,25 @@
     private Mediator mediator;
     private Operation sourceOperation;
     private Operation targetOperation;
-    private boolean copyArgs;
-    
+    private boolean passByValue;
+
     /**
      * Construct a SCABindingInvoker that delegates to the service invocaiton chain
      */
-    public SCABindingInvoker(InvocationChain chain, Operation sourceOperation, Mediator mediator) {
+    public SCABindingInvoker(InvocationChain chain, Operation sourceOperation, Mediator mediator, boolean passByValue) {
         super();
         this.chain = chain;
         this.mediator = mediator;
         this.sourceOperation = sourceOperation;
         this.targetOperation = chain.getTargetOperation();
-        initCopyArgs();
+        this.passByValue = passByValue;
     }
 
     /**
      * @see org.apache.tuscany.sca.invocation.Interceptor#getNext()
      */
     public Invoker getNext() {
-        return chain.getHeadInvoker();
+        return chain.getHeadInvoker(Phase.SERVICE_POLICY);
     }
 
     /**
@@ -68,13 +69,13 @@
      */
     public Message invoke(Message msg) {
 
-        if (copyArgs) {
+        if (passByValue) {
             msg.setBody(mediator.copyInput(msg.getBody(), sourceOperation, targetOperation));
         }
-        
+
         Message resultMsg = getNext().invoke(msg);
-        
-        if (copyArgs) {
+
+        if (passByValue) {
             // Note source and target operation swapped so result is in source class loader
             if (resultMsg.isFault()) {
                 resultMsg.setFaultBody(mediator.copyFault(resultMsg.getBody(), targetOperation, sourceOperation));
@@ -89,39 +90,6 @@
     }
 
     /**
-     * Work out if pass-by-value copies or cross classloader copies need to be done
-     * - if source and target are in different classloaders
-     * - if the interfaces are remotable unless @AllowsPassByReference or 
-     *   a data transformation has been done in the chain
-     * - what else?
-     *    - have a flag to optionally disable copies for individual composite/service/operation
-     *      to improve the performance of specific local invocations?
-     */
-    private void initCopyArgs() {
-        this.copyArgs = crossClassLoaders() || isRemotable();
-    }
-
-    private boolean crossClassLoaders() {
-        // TODO: for now if the operation is remotable the cross classloader copying will 
-        // happen automatically but this needs also to check the non-remotable operation classloaders 
-        return false;
-    }
-
-    /**
-     * Pass-by-value copies are required if the interfaces are remotable unless the
-     * implementation uses the @AllowsPassByReference annotation.
-     */
-    protected boolean isRemotable() {
-        if (!sourceOperation.getInterface().isRemotable()) {
-            return false;
-        }
-        if (!chain.getTargetOperation().getInterface().isRemotable()) {
-            return false;
-        }
-        return true;
-    }
-    
-    /**
      * @see org.apache.tuscany.sca.invocation.DataExchangeSemantics#allowsPassByReference()
      */
     public boolean allowsPassByReference() {

Modified: tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java Thu Feb 25 23:00:57 2010
@@ -79,6 +79,13 @@
      * @return The first invoker in the chain
      */
     Invoker getHeadInvoker();
+    
+    /**
+     * Get the first invoker that is on the same or later phase 
+     * @param phase
+     * @return The first invoker that is on the same or later phase
+     */
+    Invoker getHeadInvoker(String phase);
 
     /**
      * Add an interceptor to the given phase

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.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/RuntimeEndpointReferenceImpl.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java Thu Feb 25 23:00:57 2010
@@ -71,7 +71,6 @@
 import org.apache.tuscany.sca.runtime.RuntimeWireProcessor;
 import org.apache.tuscany.sca.runtime.RuntimeWireProcessorExtensionPoint;
 import org.apache.tuscany.sca.work.WorkScheduler;
-import org.oasisopen.sca.SCARuntimeException;
 import org.oasisopen.sca.ServiceRuntimeException;
 
 /**
@@ -304,7 +303,7 @@
 
         boolean ok = eprBinder.bindRunTime(endpointRegistry, this);
         if (!ok) {
-            throw new SCARuntimeException("Unable to bind " + this);
+            throw new ServiceRuntimeException("Unable to bind " + this);
         }
 
         // start the binding provider

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java Thu Feb 25 23:00:57 2010
@@ -86,6 +86,19 @@
     public Invoker getHeadInvoker() {
         return nodes.isEmpty() ? null : nodes.get(0).getInvoker();
     }
+    
+    public Invoker getHeadInvoker(String phase) {
+        int index = phaseManager.getAllPhases().indexOf(phase);
+        if (index == -1) {
+            throw new IllegalArgumentException("Invalid phase name: " + phase);
+        }
+        for (Node node : nodes) {
+            if (index <= node.getPhaseIndex()) {
+                return node.getInvoker();
+            }
+        }
+        return null;
+    }
 
     /**
      * @return the sourceOperation

Modified: tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java Thu Feb 25 23:00:57 2010
@@ -69,7 +69,7 @@
     public static final String STAGE_IMPLEMENTATION = "implementation";
 
     private static final String[] SYSTEM_REFERENCE_PHASES =
-        {REFERENCE, REFERENCE_INTERFACE, REFERENCE_POLICY, REFERENCE_BINDING};
+        {REFERENCE, REFERENCE_POLICY, REFERENCE_INTERFACE, REFERENCE_BINDING};
 
     private static final String[] SYSTEM_REFERENCE_BINDING_PHASES =
     {REFERENCE_BINDING_WIREFORMAT, REFERENCE_BINDING_POLICY, REFERENCE_BINDING_TRANSPORT};
@@ -78,7 +78,7 @@
     {SERVICE_BINDING_TRANSPORT, SERVICE_BINDING_OPERATION_SELECTOR, SERVICE_BINDING_WIREFORMAT, SERVICE_BINDING_POLICY};
     
     private static final String[] SYSTEM_SERVICE_PHASES =
-        {SERVICE_BINDING, SERVICE_POLICY, SERVICE_INTERFACE, SERVICE};
+        {SERVICE_BINDING, SERVICE_INTERFACE, SERVICE_POLICY, SERVICE};
 
     private static final String[] SYSTEM_IMPLEMENTATION_PHASES = {IMPLEMENTATION_POLICY, IMPLEMENTATION};
 

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java Thu Feb 25 23:00:57 2010
@@ -27,7 +27,7 @@
 import org.junit.After;
 import org.junit.Ignore;
 import org.junit.Test;
-import org.oasisopen.sca.SCARuntimeException;
+import org.oasisopen.sca.ServiceRuntimeException;
 
 /**
  * This shows how to test the Calculator service component.
@@ -66,7 +66,7 @@
         try {
             assertEquals("Hi Hello Petra", client.sayHello("Petra"));
             fail();
-        } catch (SCARuntimeException e) {
+        } catch (ServiceRuntimeException e) {
             // FIXME: this gives an SCARuntimeException, would be better to be something like ServiceNotFoundException?
             // expected
         }

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java?rev=916483&r1=916482&r2=916483&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java (original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java Thu Feb 25 23:00:57 2010
@@ -29,7 +29,7 @@
 import org.junit.After;
 import org.junit.Ignore;
 import org.junit.Test;
-import org.oasisopen.sca.SCARuntimeException;
+import org.oasisopen.sca.ServiceRuntimeException;
 import org.oasisopen.sca.client.SCAClientFactory;
 
 /**
@@ -69,7 +69,7 @@
         try {
             assertEquals("Hi Hello Petra", client.sayHello("Petra"));
             fail();
-        } catch (SCARuntimeException e) {
+        } catch (ServiceRuntimeException e) {
             // FIXME: this gives an SCARuntimeException, would be better to be something like ServiceNotFoundException?
             // expected
         }