diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-24 14:57:35 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-08-24 14:57:35 +0000 |
commit | 6842f1c6dcdfdb5da065ab97dfa5cb790c4473db (patch) | |
tree | d5e45928a6e2899941726a6f0a90a131ad0085df | |
parent | a90343b4cf7a42a7b5fa3cf0a0e22ff54522baeb (diff) |
Fix ASM_5021use wire target when autowire and single reference binding target@
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@807257 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java index 2adf29d33e..d9d785be1d 100644 --- a/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java +++ b/java/sca/modules/assembly/src/main/java/org/apache/tuscany/sca/assembly/builder/impl/ComponentReferenceEndpointReferenceBuilderImpl.java @@ -199,6 +199,8 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI } } + setSingleAutoWireTarget(reference); + } else if (!refTargets.isEmpty()) { // Check that the component reference does not mix the use of endpoint references // specified via the target attribute with the presence of binding elements @@ -1163,4 +1165,32 @@ public class ComponentReferenceEndpointReferenceBuilderImpl extends BaseBuilderI return endpoint; } // end method createEndpoint + /** + * ASM_5021: where a <reference/> of a <component/> has @autowire=true + * and where the <reference/> has a <binding/> child element which + * declares a single target service, the reference is wired only to + * the single service identified by the <wire/> element + */ + private void setSingleAutoWireTarget(ComponentReference reference) { + if (reference.getEndpointReferences().size() > 1 && reference.getBindings() != null && reference.getBindings().size() == 1) { + String uri = reference.getBindings().get(0).getURI(); + if (uri != null) { + if (uri.indexOf('/') > -1) { + // TODO: must be a way to avoid this fiddling + int i = uri.indexOf('/'); + String c = uri.substring(0, i); + String s = uri.substring(i+1); + uri = c + "#service(" + s + ")"; + } + for (EndpointReference er : reference.getEndpointReferences()) { + if (er.getTargetEndpoint().getURI().equals(uri)) { + reference.getEndpointReferences().clear(); + reference.getEndpointReferences().add(er); + return; + } + } + } + } + } + } // end class |