summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java37
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java6
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java1
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java2
-rw-r--r--sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java2
-rw-r--r--sca-java-2.x/trunk/itest/nodes/pom.xml1
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java10
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java19
-rw-r--r--sca-java-2.x/trunk/modules/binding-http-runtime/META-INF/MANIFEST.MF1
-rw-r--r--sca-java-2.x/trunk/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java9
-rw-r--r--sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java56
-rw-r--r--sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java52
-rw-r--r--sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java7
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java3
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java13
-rw-r--r--sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java4
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java4
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java4
18 files changed, 146 insertions, 85 deletions
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java
index baf4d69508..88d1e201f1 100644
--- a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/BindingSCATestCase.java
@@ -26,7 +26,7 @@ import org.apache.tuscany.sca.node.NodeFactory;
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 @@ public class BindingSCATestCase {
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 @@ public class BindingSCATestCase {
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 @@ public class BindingSCATestCase {
String id = client.create("Ray");
Assert.assertEquals("Ray", client.getName(id));
}
-
+
/**
* One node factory and one node for both composites
*/
@@ -130,9 +134,12 @@ public class BindingSCATestCase {
Node node1 = factory.createNode(config1);
node1.start();
- runClient(node1);
- node1.stop();
- factory.destroy();
+ try {
+ runClient(node1);
+ } finally {
+ node1.stop();
+ factory.destroy();
+ }
}
}
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java
index d9436e8ea5..7255697d4b 100644
--- a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedCustomerTestCase.java
@@ -31,12 +31,13 @@ import org.junit.Test;
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 @@ public class ClientNodeSharedCustomerTestCase {
if (runner != null) {
runner.afterClass();
}
+ if (factory != null) {
+ factory.destroy();
+ }
}
}
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java
index c29dfe4ae4..51fafae32c 100644
--- a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientNodeSharedLocalTestCase.java
@@ -57,5 +57,6 @@ public class ClientNodeSharedLocalTestCase {
if (runner != null) {
runner.afterClass();
}
+ NodeFactory.getInstance().destroy();
}
}
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java
index 13dd048f1f..b8ff0c58ba 100644
--- a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedCustomerTestCase.java
@@ -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 @@ public class ClientSharedCustomerTestCase {
if (runner != null) {
runner.afterClass();
}
+ NodeFactory.getInstance().destroy();
}
}
diff --git a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java
index d48b18f83a..034136ca53 100644
--- a/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java
+++ b/sca-java-2.x/trunk/itest/nodes/binding-sca-tribes/src/test/java/org/apache/tuscany/sca/itest/bindingsca/ClientSharedLocalTestCase.java
@@ -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 @@ public class ClientSharedLocalTestCase {
if (runner != null) {
runner.afterClass();
}
+ NodeFactory.getInstance().destroy();
}
}
diff --git a/sca-java-2.x/trunk/itest/nodes/pom.xml b/sca-java-2.x/trunk/itest/nodes/pom.xml
index a347da0ebd..c578a0ba56 100644
--- a/sca-java-2.x/trunk/itest/nodes/pom.xml
+++ b/sca-java-2.x/trunk/itest/nodes/pom.xml
@@ -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>
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java
index 7a917e5560..5ce1baa54c 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/InterfaceContractMapper.java
@@ -78,15 +78,21 @@ public interface InterfaceContractMapper {
* 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
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
index dc1c0c0a4e..5c561b2ddf 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/interfacedef/impl/InterfaceContractMapperImpl.java
@@ -116,6 +116,10 @@ public class InterfaceContractMapperImpl implements InterfaceContractMapper {
} // 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 @@ public class InterfaceContractMapperImpl implements InterfaceContractMapper {
return false;
}
- boolean remotable = source.getInterface().isRemotable();
+ boolean passByValue = (source.getInterface().isRemotable()) && byValue;
// if (source.getInterface().isRemotable()) {
// return true;
@@ -164,7 +168,7 @@ public class InterfaceContractMapperImpl implements InterfaceContractMapper {
return true;
}
- if (!isCompatible(targetOutputType, sourceOutputType, remotable)) {
+ if (!isCompatible(targetOutputType, sourceOutputType, passByValue)) {
return false;
}
@@ -174,7 +178,7 @@ public class InterfaceContractMapperImpl implements InterfaceContractMapper {
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 @@ public class InterfaceContractMapperImpl implements InterfaceContractMapper {
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 @@ public class InterfaceContractMapperImpl implements InterfaceContractMapper {
}
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
diff --git a/sca-java-2.x/trunk/modules/binding-http-runtime/META-INF/MANIFEST.MF b/sca-java-2.x/trunk/modules/binding-http-runtime/META-INF/MANIFEST.MF
index 15538785c4..175d11f601 100644
--- a/sca-java-2.x/trunk/modules/binding-http-runtime/META-INF/MANIFEST.MF
+++ b/sca-java-2.x/trunk/modules/binding-http-runtime/META-INF/MANIFEST.MF
@@ -12,6 +12,7 @@ Import-Package: javax.servlet,
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",
diff --git a/sca-java-2.x/trunk/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java
index 6df0fcefc4..318ffd05bf 100644
--- a/sca-java-2.x/trunk/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-sca-axis2-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/axis2/impl/Axis2SCAReferenceBindingProvider.java
@@ -34,6 +34,7 @@ import org.apache.tuscany.sca.interfacedef.InterfaceContract;
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 @@ import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
* 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 class Axis2SCAReferenceBindingProvider implements ReferenceBindingProvide
public void stop() {
axisReferenceBindingProvider.stop();
}
+
+ public void configure() {
+ if (axisReferenceBindingProvider instanceof EndpointReferenceProvider) {
+ ((EndpointReferenceProvider)axisReferenceBindingProvider).configure();
+ }
+ }
}
diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java
index ec4e893b5f..3ace5a7d01 100644
--- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java
+++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java
@@ -29,11 +29,14 @@ import org.apache.tuscany.sca.core.ExtensionPointRegistry;
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.RuntimeComponentReference;
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 @@ import org.oasisopen.sca.ServiceUnavailableException;
*
* @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 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi
private ReferenceBindingProvider distributedProvider = null;
private SCABindingFactory scaBindingFactory;
private Mediator mediator;
+ private InterfaceContractMapper interfaceContractMapper;
public RuntimeSCAReferenceBindingProvider(ExtensionPointRegistry extensionPoints,
RuntimeEndpointReference endpointReference) {
@@ -85,10 +90,14 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi
(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 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi
targetIsRemote = false;
}
return targetIsRemote;
+ */
}
private ReferenceBindingProvider getDistributedProvider() {
@@ -127,14 +137,14 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi
// 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 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi
return false;
}
}
+
private Invoker getInvoker(RuntimeEndpointReference epr, Operation operation) {
Endpoint target = epr.getTargetEndpoint();
@@ -190,10 +201,24 @@ public class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi
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 class RuntimeSCAReferenceBindingProvider implements ReferenceBindingProvi
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();
}
+
}
}
diff --git a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java
index 0f46e9390f..cbe836954d 100644
--- a/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java
+++ b/sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/SCABindingInvoker.java
@@ -26,6 +26,7 @@ import org.apache.tuscany.sca.invocation.Interceptor;
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 @@ public class SCABindingInvoker implements Interceptor, DataExchangeSemantics {
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 class SCABindingInvoker implements Interceptor, DataExchangeSemantics {
*/
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 @@ public class SCABindingInvoker implements Interceptor, DataExchangeSemantics {
}
/**
- * 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() {
diff --git a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java
index 4f131365fa..b85905b561 100644
--- a/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java
+++ b/sca-java-2.x/trunk/modules/core-spi/src/main/java/org/apache/tuscany/sca/invocation/InvocationChain.java
@@ -79,6 +79,13 @@ public interface InvocationChain {
* @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
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
index 940155d613..ff290ee150 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/assembly/impl/RuntimeEndpointReferenceImpl.java
@@ -71,7 +71,6 @@ import org.apache.tuscany.sca.runtime.RuntimeEndpointReference;
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 @@ public class RuntimeEndpointReferenceImpl extends EndpointReferenceImpl implemen
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
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java
index 60914f799b..8569af0de8 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/InvocationChainImpl.java
@@ -86,6 +86,19 @@ public class InvocationChainImpl implements InvocationChain {
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
diff --git a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java
index 1649eade87..85ef79b5d7 100644
--- a/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java
+++ b/sca-java-2.x/trunk/modules/core/src/main/java/org/apache/tuscany/sca/core/invocation/impl/PhaseManager.java
@@ -69,7 +69,7 @@ public class PhaseManager {
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 @@ public class PhaseManager {
{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};
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
index a7bcd0f420..596febe393 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/GetServiceTestCase.java
@@ -27,7 +27,7 @@ import itest.nodes.Helloworld;
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 @@ public class GetServiceTestCase{
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
}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
index 765f3ab7ba..3583b1be15 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/domain/node/MultipleNodesPerJVMTestCase.java
@@ -29,7 +29,7 @@ import java.net.URI;
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 @@ public class MultipleNodesPerJVMTestCase{
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
}