Rashmi Hunt created TUSCANY-4069:
------------------------------------
Summary: Issue with resolving autowired reference when binding is
not defined to a target service exposed over multiple bindings
Key: TUSCANY-4069
URL: https://issues.apache.org/jira/browse/TUSCANY-4069
Project: Tuscany
Issue Type: Bug
Components: Java SCA Assembly Model
Affects Versions: Java-SCA-2.0-Beta3
Reporter: Rashmi Hunt
This issue is somewhat similar to TUSCANY-3941, with difference that the
autowired reference without
any binding defined, gets matched to a first binding on the target service with
multiple bindings even
though binding.sca is one of them.
E.g
<component name="Calculator" autowire="true" >
<implementation.java class="test.sca.calculator.Calculator"/>
<service name="CalculatorService">
<binding.sca/>
</service>
<reference name="add" multiplicity="1..1">
<interface.java interface="test.sca.add.AddLocal"/>
</reference>
</component>
<component name="Add">
<implementation.java class="test.sca.add.AddDelegate"/>
<service name="AddLocal">
<binding.ws name="ws"/>
<binding.sca/>
</service>
</component>
Since above autowired reference "add" in component "Calculator" is defined
without any binding, I would
think the runtime would match it to <binding.sca> of the target Service.
Instead for this reference,
runtime matches to first binding of the target service, which is binding.ws
instead of matching to
binding.sca even though binding.sca is one of the bindings defined in the
target service.
Fix can be, in EndpointReferenceBinderImpl.selectForwardEndpoint(..) add below
logic,
if (endpointReference.getBinding() == null &&
endpointReference.getReference().getAutowire() == true){
for (Endpoint endpoint : matchedEndpoints){
if (endpoint.getBinding() instanceof SCABinding){
matchedEndpoint = endpoint;
break;
}
}
}
after,
// TUSCANY-3941 check for the case where the user has provided a
// binding.sca at the reference and make sure we pick
// a binding.sca at the service regardless of how many
// other bindings are provided
if (endpointReference.getBinding() != null &&
endpointReference.getBinding() instanceof SCABinding ){
for (Endpoint endpoint : matchedEndpoints){
if (endpoint.getBinding() instanceof SCABinding){
matchedEndpoint = endpoint;
break;
}
}
}
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira