summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.3.3/modules
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-10-17 13:08:08 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-10-17 13:08:08 +0000
commitf343f1d8336d5045d7aacb8f949658b2e34f709f (patch)
tree840ba69cdbf55ab31bf608b96a3bc854e99432a8 /branches/sca-java-1.3.3/modules
parent566605c662d21034391a548a51c9b7c68addfc4e (diff)
TUSCANY-2617 if a reference already has a target don't try to autowire it
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@705599 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.3.3/modules')
-rw-r--r--branches/sca-java-1.3.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java92
1 files changed, 46 insertions, 46 deletions
diff --git a/branches/sca-java-1.3.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java b/branches/sca-java-1.3.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
index 0c2d02ab48..b2f662918c 100644
--- a/branches/sca-java-1.3.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
+++ b/branches/sca-java-1.3.3/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
@@ -401,50 +401,7 @@ class BaseWireBuilderImpl {
List<Endpoint> endpoints = new ArrayList<Endpoint>();
- if (componentReference.getAutowire() == Boolean.TRUE) {
-
- // Find suitable targets in the current composite for an
- // autowired reference
- Multiplicity multiplicity = componentReference.getMultiplicity();
- for (Component targetComponent : composite.getComponents()) {
- // prevent autowire connecting to self
- boolean skipSelf = false;
- for (ComponentReference targetComponentReference : targetComponent.getReferences()) {
- if (componentReference == targetComponentReference){
- skipSelf = true;
- }
- }
-
- if (!skipSelf){
- for (ComponentService targetComponentService : targetComponent.getServices()) {
- if (componentReference.getInterfaceContract() == null ||
- interfaceContractMapper.isCompatible(componentReference.getInterfaceContract(), targetComponentService.getInterfaceContract())) {
-
- Endpoint endpoint = endpointFactory.createEndpoint();
- endpoint.setTargetName(targetComponent.getName());
- endpoint.setSourceComponent(null); // TODO - fixed up at start
- endpoint.setSourceComponentReference(componentReference);
- endpoint.setInterfaceContract(componentReference.getInterfaceContract());
- endpoint.setTargetComponent(targetComponent);
- endpoint.setTargetComponentService(targetComponentService);
- endpoint.getCandidateBindings().addAll(componentReference.getBindings());
- endpoints.add(endpoint);
-
- if (multiplicity == Multiplicity.ZERO_ONE || multiplicity == Multiplicity.ONE_ONE) {
- break;
- }
- }
- }
- }
- }
-
- if (multiplicity == Multiplicity.ONE_N || multiplicity == Multiplicity.ONE_ONE) {
- if (endpoints.size() == 0) {
- warning("NoComponentReferenceTarget", componentReference, componentReference.getName());
- }
- }
-
- } else if (!componentReference.getTargets().isEmpty()) {
+ if (!componentReference.getTargets().isEmpty()) {
// Check if the component reference does not mix the use of endpoints specified via
// binding elements with target endpoints specified via the target attribute
@@ -511,7 +468,8 @@ class BaseWireBuilderImpl {
composite.getName().toString(), componentService.getName());
}
}
- } else if (componentReference.getReference() != null) {
+ } else if ((componentReference.getReference() != null) &&
+ (!componentReference.getReference().getTargets().isEmpty())) {
// Resolve targets from the corresponding reference in the
// componentType
@@ -573,7 +531,49 @@ class BaseWireBuilderImpl {
composite.getName().toString(), componentService.getName());
}
}
- }
+ } else if (componentReference.getAutowire() == Boolean.TRUE) {
+
+ // Find suitable targets in the current composite for an
+ // autowired reference
+ Multiplicity multiplicity = componentReference.getMultiplicity();
+ for (Component targetComponent : composite.getComponents()) {
+ // prevent autowire connecting to self
+ boolean skipSelf = false;
+ for (ComponentReference targetComponentReference : targetComponent.getReferences()) {
+ if (componentReference == targetComponentReference){
+ skipSelf = true;
+ }
+ }
+
+ if (!skipSelf){
+ for (ComponentService targetComponentService : targetComponent.getServices()) {
+ if (componentReference.getInterfaceContract() == null ||
+ interfaceContractMapper.isCompatible(componentReference.getInterfaceContract(), targetComponentService.getInterfaceContract())) {
+
+ Endpoint endpoint = endpointFactory.createEndpoint();
+ endpoint.setTargetName(targetComponent.getName());
+ endpoint.setSourceComponent(null); // TODO - fixed up at start
+ endpoint.setSourceComponentReference(componentReference);
+ endpoint.setInterfaceContract(componentReference.getInterfaceContract());
+ endpoint.setTargetComponent(targetComponent);
+ endpoint.setTargetComponentService(targetComponentService);
+ endpoint.getCandidateBindings().addAll(componentReference.getBindings());
+ endpoints.add(endpoint);
+
+ if (multiplicity == Multiplicity.ZERO_ONE || multiplicity == Multiplicity.ONE_ONE) {
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ if (multiplicity == Multiplicity.ONE_N || multiplicity == Multiplicity.ONE_ONE) {
+ if (endpoints.size() == 0) {
+ warning("NoComponentReferenceTarget", componentReference, componentReference.getName());
+ }
+ }
+ }
// if no endpoints have found so far retrieve any target names that are in binding URIs