summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java14
-rw-r--r--branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java17
-rw-r--r--branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java11
-rw-r--r--branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java21
-rw-r--r--branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java8
-rw-r--r--branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java8
6 files changed, 69 insertions, 10 deletions
diff --git a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
index 55540452af..f9a62774e6 100644
--- a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
+++ b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/Contract.java
@@ -20,6 +20,7 @@ package org.apache.tuscany.sca.assembly;
import java.util.List;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
/**
@@ -78,4 +79,17 @@ public interface Contract extends AbstractContract, PolicySetAttachPoint, Clonea
*/
Object clone() throws CloneNotSupportedException;
+ /**
+ * Returns the interface contract given a binding. Important in the case where
+ * a reference with multiplicity > 1 has been promoted and has it's list of
+ * resolved bindings extended by a promoting reference. Here the binding
+ * from the promoting reference may need the interface contract from the
+ * promoting reference and not the promoted reference.
+ * TODO - remove this wrinkle with better endpoint support.
+ *
+ * @param binding the binding for which the interface contract is required
+ * @return the interface contract
+ */
+ InterfaceContract getInterfaceContract(Binding binding);
+
}
diff --git a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
index c5faa46f85..9c0dd62dff 100644
--- a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
+++ b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
@@ -639,16 +639,13 @@ class BaseWireBuilderImpl {
}
} else {
- /* TODO - don't enable this yet as we have tests that
- use relative URIs in bindings that don't refer to
- targets
+ // create endpoints for manually configured bindings
Endpoint endpoint = endpointFactory.createEndpoint();
endpoint.setTargetName(uri);
endpoint.setSourceComponent(null); // TODO - fixed up at start
endpoint.setSourceComponentReference(componentReference);
- endpoint.getCandidateBindings().add(binding);
+ endpoint.setSourceBinding(binding);
endpoints.add(endpoint);
- */
}
}
}
@@ -679,8 +676,16 @@ class BaseWireBuilderImpl {
componentReference.getEndpoints().addAll(endpoints);
+ // the result of calculating the endpoints is either that bindings have been
+ // configured manually using a URI or that targets have been provided and the
+ // endpoint remains unresolved. So all endpoints should be either resved or uresolved.
+ boolean endpointsRequireAutomaticResolution = false;
+ for(Endpoint endpoint : endpoints){
+ endpointsRequireAutomaticResolution = endpoint.isUnresolved();
+ }
+
// build each endpoint
- if (!endpoints.isEmpty()) {
+ if (endpointsRequireAutomaticResolution) {
for(Endpoint endpoint : endpoints){
endpointBuilder.build(endpoint);
diff --git a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java
index b7fba86e07..c7418913ed 100644
--- a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java
+++ b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ReferenceConfigurationUtil.java
@@ -185,9 +185,11 @@ abstract class ReferenceConfigurationUtil {
for (Binding binding : reference.getBindings()) {
if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) {
promotedReference.getBindings().add(binding);
-
// TUSCANY-2324: ensure that the promoted reference can identify the
// correct interface contract for this binding
+ // TODO - Remove and use Reference.getInterfaceContract(binding)
+ // in any binding that needs to use the interface contract
+ // from the promoting reference
promotedReference.setInterfaceContract(reference.getInterfaceContract());
}
}
@@ -209,11 +211,12 @@ abstract class ReferenceConfigurationUtil {
for (Binding binding : reference.getBindings()) {
if ((!(binding instanceof OptimizableBinding)) || binding.getURI() != null) {
promotedReference.getBindings().add(binding);
-
// TUSCANY-2324: ensure that the promoted reference can identify the
// correct interface contract for this binding
- // TODO: no such interface exists yet!
- //promotedReference.setInterfaceContract(binding, reference.getInterfaceContract());
+ // TODO: use Reference.getInterfaceContract(binding) when the interface contract is required
+ // in any binding that needs to use the interface contract
+ // from the promoting reference
+ //promotedReference.setInterfaceContract(binding, reference.getInterfaceContract());
}
}
}
diff --git a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
index b3fdd32aee..250db31cb6 100644
--- a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
+++ b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ComponentReferenceImpl.java
@@ -22,11 +22,13 @@ package org.apache.tuscany.sca.assembly.impl;
import java.util.ArrayList;
import java.util.List;
+import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.ComponentReference;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.CompositeReference;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
/**
* Represents a component reference
@@ -88,4 +90,23 @@ public class ComponentReferenceImpl extends ReferenceImpl implements ComponentRe
public List<Endpoint> getEndpoints(){
return endpoints;
}
+
+ /**
+ * Use endpoint information to work out what the interface contract for the
+ * binding is.
+ */
+ public InterfaceContract getInterfaceContract(Binding binding){
+ InterfaceContract interfaceContract = null;
+
+ for (Endpoint theEndpoint : endpoints){
+ if (theEndpoint.getSourceBinding() == binding){
+ interfaceContract = theEndpoint.getSourceComponentReference().getInterfaceContract();
+ }
+ }
+
+ if (interfaceContract == null){
+ interfaceContract = getInterfaceContract();
+ }
+ return interfaceContract;
+ }
}
diff --git a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
index 12dda94b7a..1800222bfb 100644
--- a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
+++ b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ReferenceImpl.java
@@ -26,6 +26,7 @@ import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Callback;
import org.apache.tuscany.sca.assembly.ComponentService;
import org.apache.tuscany.sca.assembly.Reference;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -121,5 +122,12 @@ public class ReferenceImpl extends AbstractReferenceImpl implements Reference, C
public void setPolicySets(List<PolicySet> policySets) {
this.policySets = policySets;
}
+
+ /**
+ * By default return the interface contract for the reference
+ */
+ public InterfaceContract getInterfaceContract(Binding binding){
+ return getInterfaceContract();
+ }
}
diff --git a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
index bee7cbec2d..8d745cb7e1 100644
--- a/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
+++ b/branches/sca-java-1.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/impl/ServiceImpl.java
@@ -25,6 +25,7 @@ import java.util.List;
import org.apache.tuscany.sca.assembly.Binding;
import org.apache.tuscany.sca.assembly.Callback;
import org.apache.tuscany.sca.assembly.Service;
+import org.apache.tuscany.sca.interfacedef.InterfaceContract;
import org.apache.tuscany.sca.policy.PolicySet;
/**
@@ -95,5 +96,12 @@ public class ServiceImpl extends AbstractServiceImpl implements Service, Cloneab
public void setPolicySets(List<PolicySet> policySets) {
this.policySets = policySets;
}
+
+ /**
+ * By default return the interface contract for the service
+ */
+ public InterfaceContract getInterfaceContract(Binding binding){
+ return getInterfaceContract();
+ }
}