summaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-11-07 07:28:24 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-11-07 07:28:24 +0000
commit5bec3f82f6408873f6f314022738c63da2f7c84a (patch)
tree85d618e6c8d71e205fa01b39c8fd14bac7d42850 /java
parent2fa2269bd4a993217302183736e6dd0888656869 (diff)
Fix for ASM_6016 - only autowire a reference if its intents match the service intents
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@833640 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java')
-rw-r--r--java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java28
1 files changed, 20 insertions, 8 deletions
diff --git a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
index cfecb2be17..df941e8879 100644
--- a/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
+++ b/java/sca/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/EndpointReferenceBuilderImpl.java
@@ -21,8 +21,10 @@ package org.apache.tuscany.sca.builder.impl;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Binding;
@@ -46,6 +48,7 @@ import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
import org.apache.tuscany.sca.interfacedef.InterfaceContractMapper;
import org.apache.tuscany.sca.monitor.Monitor;
+import org.apache.tuscany.sca.policy.Intent;
/**
* Creates endpoint reference models.
@@ -357,16 +360,19 @@ public class EndpointReferenceBuilderImpl {
for (ComponentService targetComponentService : targetComponent.getServices()) {
if (reference.getInterfaceContract() == null || interfaceContractMapper.isCompatible(reference
.getInterfaceContract(), targetComponentService.getInterfaceContract())) {
+
+ if (intentsMatch(reference.getRequiredIntents(), targetComponentService.getRequiredIntents())) {
+ EndpointReference endpointRef = createEndpointRef(component, reference, false);
+ endpointRef.setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true));
+ endpointRef.setStatus(EndpointReference.WIRED_TARGET_FOUND_READY_FOR_MATCHING);
+ reference.getEndpointReferences().add(endpointRef);
- EndpointReference endpointRef = createEndpointRef(component, reference, false);
- endpointRef.setTargetEndpoint(createEndpoint(targetComponent, targetComponentService, true));
- endpointRef.setStatus(EndpointReference.WIRED_TARGET_FOUND_READY_FOR_MATCHING);
- reference.getEndpointReferences().add(endpointRef);
+ // Stop with the first match for 0..1 and 1..1 references
+ if (multiplicity == Multiplicity.ZERO_ONE || multiplicity == Multiplicity.ONE_ONE) {
+ break;
+ } // end if
+ }
- // Stop with the first match for 0..1 and 1..1 references
- if (multiplicity == Multiplicity.ZERO_ONE || multiplicity == Multiplicity.ONE_ONE) {
- break;
- } // end if
} // end if
} // end for
} // end for
@@ -609,6 +615,12 @@ public class EndpointReferenceBuilderImpl {
} // end method
+ private boolean intentsMatch(List<Intent> referenceIntents, List<Intent> serviceIntents) {
+ Set<Intent> referenceIntentSet = new HashSet<Intent>(referenceIntents);
+ Set<Intent> serviceIntentSet = new HashSet<Intent>(serviceIntents);
+ return referenceIntentSet.equals(serviceIntentSet);
+ }
+
/**
* Reference targets have to be resolved in the context in which they are
* defined so they can't be push down the hierarchy during the static build.