summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java11
-rw-r--r--sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java9
-rw-r--r--sca-java-2.x/trunk/modules/binding-sca-runtime/src/main/java/org/apache/tuscany/sca/binding/sca/provider/RuntimeSCAReferenceBindingProvider.java6
-rw-r--r--sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java5
-rw-r--r--sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java10
-rw-r--r--sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java17
-rw-r--r--sca-java-2.x/trunk/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java1
-rw-r--r--sca-java-2.x/trunk/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java6
8 files changed, 50 insertions, 15 deletions
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
index 2ee3e774e4..db677bdabb 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Reference.java
@@ -67,5 +67,14 @@ public interface Reference extends AbstractReference, Contract {
* @return the endpoint references implied by this reference
*/
List<EndpointReference> getEndpointReferences();
-
+
+ /**
+ * Indicate if the reference allows pass by reference for remotable operations
+ */
+ boolean isAllowsPassByReference();
+
+ /**
+ * @param allowsPassByReference the allowsPassByReference to set
+ */
+ void setAllowsPassByReference(boolean allowsPassByReference);
}
diff --git a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
index 69d76f238d..f0c884797c 100644
--- a/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
+++ b/sca-java-2.x/trunk/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
@@ -41,6 +41,7 @@ public class ReferenceImpl extends AbstractReferenceImpl implements Reference, C
private List<ComponentService> targets = new ArrayList<ComponentService>();
private Callback callback;
private boolean overridingBindings;
+ private boolean allowsPassByReference;
private List<EndpointReference> endpointReferences = new ArrayList<EndpointReference>();
/**
@@ -132,4 +133,12 @@ public class ReferenceImpl extends AbstractReferenceImpl implements Reference, C
public void setOverridingBindings(boolean overridingBindings) {
this.overridingBindings = overridingBindings;
}
+
+ public boolean isAllowsPassByReference() {
+ return allowsPassByReference;
+ }
+
+ public void setAllowsPassByReference(boolean allowsPassByReference) {
+ this.allowsPassByReference = allowsPassByReference;
+ }
}
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 6bda9f0c2d..3d159fcae7 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
@@ -20,6 +20,7 @@
package org.apache.tuscany.sca.binding.sca.provider;
import org.apache.tuscany.sca.assembly.Endpoint;
+import org.apache.tuscany.sca.assembly.Reference;
import org.apache.tuscany.sca.assembly.SCABinding;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
@@ -144,8 +145,9 @@ public class RuntimeSCAReferenceBindingProvider implements EndpointReferenceAsyn
passByValue = false;
}
} else {
-// boolean allowsPBR = chain.allowsPassByReference(); TODO: TUSCANY-3479 this breaks the conformance tests as it needs to consider _both_ ends
- boolean allowsPBR = false;
+ Reference ref = epr.getReference().getReference();
+ boolean allowsPBR = (ref != null && ref.isAllowsPassByReference()) || chain.allowsPassByReference();
+
if (allowsPBR && interfaceContractMapper.isCompatibleByReference(operation,
targetOp,
Compatibility.SUBSET)) {
diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
index 1a5051dd95..c32968fd87 100644
--- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
+++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
@@ -18,7 +18,6 @@
*/
package org.apache.tuscany.sca.builder.impl;
-import java.io.IOException;
import java.io.InputStream;
import java.io.StringReader;
import java.net.URI;
@@ -77,11 +76,9 @@ import org.apache.tuscany.sca.definitions.Definitions;
import org.apache.tuscany.sca.interfacedef.Compatibility;
import org.apache.tuscany.sca.interfacedef.DataType;
import org.apache.tuscany.sca.interfacedef.IncompatibleInterfaceContractException;
-import org.apache.tuscany.sca.interfacedef.Interface;
import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.interfacedef.impl.DataTypeImpl;
-import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
import org.apache.tuscany.sca.interfacedef.util.XMLType;
import org.apache.tuscany.sca.monitor.Monitor;
@@ -1236,6 +1233,8 @@ public class ComponentBuilderImpl {
} catch (CloneNotSupportedException e) {
// will not happen
}
+ // FIXME: We need to set the allowsPassByReference flag based on the annotations on the implementation and callback
+ // implReference.setAllowsPassByReference(allowsPassByReference);
callbackReference.setReference(implReference);
}
component.getReferences().add(callbackReference);
diff --git a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
index 67bbe32c27..0b97192cc6 100644
--- a/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
+++ b/sca-java-2.x/trunk/modules/implementation-java-runtime/src/main/java/org/apache/tuscany/sca/implementation/java/invocation/JavaImplementationInvoker.java
@@ -40,6 +40,7 @@ import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.interfacedef.ParameterMode;
import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.interfacedef.java.impl.JavaInterfaceUtil;
+import org.apache.tuscany.sca.invocation.DataExchangeSemantics;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.Message;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -52,7 +53,7 @@ import org.oasisopen.sca.ServiceRuntimeException;
*
* @version $Rev$ $Date$
*/
-public class JavaImplementationInvoker implements Invoker {
+public class JavaImplementationInvoker implements Invoker, DataExchangeSemantics {
protected Operation operation;
protected Method method;
protected boolean allowsPBR;
@@ -272,6 +273,11 @@ public class JavaImplementationInvoker implements Invoker {
}
}
- }
+ }
+
+ @Override
+ public boolean allowsPassByReference() {
+ return allowsPBR;
+ }
}
diff --git a/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java b/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
index b5c3806166..225099758d 100644
--- a/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
+++ b/sca-java-2.x/trunk/modules/implementation-java/src/main/java/org/apache/tuscany/sca/implementation/java/introspect/impl/ReferenceProcessor.java
@@ -43,6 +43,7 @@ import org.apache.tuscany.sca.interfacedef.java.JavaInterface;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceContract;
import org.apache.tuscany.sca.interfacedef.java.JavaInterfaceFactory;
import org.oasisopen.sca.ServiceReference;
+import org.oasisopen.sca.annotation.AllowsPassByReference;
import org.oasisopen.sca.annotation.Reference;
/**
@@ -88,7 +89,7 @@ public class ReferenceProcessor extends BaseJavaClassVisitor {
removeReference(ref, type);
JavaElementImpl element = new JavaElementImpl(method, 0);
- org.apache.tuscany.sca.assembly.Reference reference = createReference(element, name);
+ org.apache.tuscany.sca.assembly.Reference reference = createReference(type, element, name);
type.getReferences().add(reference);
type.getReferenceMembers().put(name, element);
}
@@ -128,7 +129,7 @@ public class ReferenceProcessor extends BaseJavaClassVisitor {
// Setter method override field
if (ref == null) {
JavaElementImpl element = new JavaElementImpl(field);
- org.apache.tuscany.sca.assembly.Reference reference = createReference(element, name);
+ org.apache.tuscany.sca.assembly.Reference reference = createReference(type, element, name);
type.getReferences().add(reference);
type.getReferenceMembers().put(name, element);
}
@@ -160,7 +161,7 @@ public class ReferenceProcessor extends BaseJavaClassVisitor {
}
removeReference(ref, type);
- org.apache.tuscany.sca.assembly.Reference reference = createReference(parameter, name);
+ org.apache.tuscany.sca.assembly.Reference reference = createReference(type, parameter, name);
type.getReferences().add(reference);
type.getReferenceMembers().put(name, parameter);
parameter.setClassifer(Reference.class);
@@ -169,16 +170,24 @@ public class ReferenceProcessor extends BaseJavaClassVisitor {
/**
* Create a SCA reference for a java Element
+ * @param implementation TODO
* @param element
* @param name
* @return
* @throws IntrospectionException
*/
- private org.apache.tuscany.sca.assembly.Reference createReference(JavaElementImpl element, String name)
+ private org.apache.tuscany.sca.assembly.Reference createReference(JavaImplementation implementation, JavaElementImpl element, String name)
throws IntrospectionException {
org.apache.tuscany.sca.assembly.Reference reference = assemblyFactory.createReference();
JavaInterfaceContract interfaceContract = javaInterfaceFactory.createJavaInterfaceContract();
reference.setInterfaceContract(interfaceContract);
+
+ AllowsPassByReference pbr = element.getAnnotation(AllowsPassByReference.class);
+ if (pbr != null) {
+ reference.setAllowsPassByReference(true);
+ } else {
+ reference.setAllowsPassByReference(implementation.isAllowsPassByReference());
+ }
// reference.setMember((Member)element.getAnchor());
boolean required = true;
diff --git a/sca-java-2.x/trunk/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java b/sca-java-2.x/trunk/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java
index 541b1f1508..efeb6f91fe 100644
--- a/sca-java-2.x/trunk/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java
+++ b/sca-java-2.x/trunk/testing/itest/interfaces/src/main/java/org/apache/tuscany/sca/itest/interfaces/RemoteClientComponentImpl.java
@@ -27,6 +27,7 @@ import org.oasisopen.sca.annotation.Service;
public class RemoteClientComponentImpl implements RemoteClientComponent, RemoteCallbackInterface {
@Reference
+ @AllowsPassByReference
protected RemoteServiceComponent aCallBackService;
private static String callbackValue;
private static String onewayValue;
diff --git a/sca-java-2.x/trunk/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java b/sca-java-2.x/trunk/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java
index d04351f51e..3936600cb7 100644
--- a/sca-java-2.x/trunk/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java
+++ b/sca-java-2.x/trunk/testing/itest/interfaces/src/test/java/org/apache/tuscany/sca/itest/interfaces/InterfacesTestCase.java
@@ -105,9 +105,9 @@ public class InterfacesTestCase {
assertEquals("BBComponent1", remote.foo2(1, "B"));
// TODO: TUSCANY-3479, investigate Node/SCAClient pass by reference
-// // Test allowsPassByReference
-// assertEquals("BComponent", remote.foo3(po));
-// assertEquals("BComponent", po.field1);
+ // Test allowsPassByReference
+ assertEquals("BComponent", remote.foo3(po));
+ assertEquals("BComponent", po.field1);
} catch (Exception e) {
e.printStackTrace();
fail();