summaryrefslogtreecommitdiffstats
path: root/java/sca/modules
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-10-06 09:15:42 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2008-10-06 09:15:42 +0000
commit9021748796530260d31c99e00e144302879d7a1b (patch)
treeadf83e3236a11b96ddfa3060ddcf6403f5c92738 /java/sca/modules
parent6560ed29512856e23aa6c21a1d8cab0c778c5829 (diff)
TUSCANY-2617 perform autowire processing after all targets have been processes. In this was explicitly specified targets will take precedence over autwires as described in the assembly spec.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@702034 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules')
-rw-r--r--java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java92
1 files changed, 46 insertions, 46 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
index 0c2d02ab48..b2f662918c 100644
--- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/BaseWireBuilderImpl.java
+++ b/java/sca/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