sourceContract = componentTypeRef.getInterfaceContract();
}
sourceContract = sourceContract.makeUnidirectional(false);
EndpointReference wireSource =
new EndpointReferenceImpl((RuntimeComponent)refComponent, reference, refBinding, sourceContract);
ComponentService callbackService = reference.getCallbackService();
if (callbackService != null) {
// select a reference callback binding to pass with invocations on this wire
Binding callbackBinding = null;
for (Binding binding : callbackService.getBindings()) {
// first look for a callback binding whose name matches the reference binding name
if (refBinding.getName().startsWith(binding.getName())) {
callbackBinding = binding;
break;
}
}
// if no callback binding found, try again based on reference binding type
if (callbackBinding == null) {
callbackBinding = callbackService.getBinding(refBinding.getClass());
}
InterfaceContract callbackContract = callbackService.getInterfaceContract();
EndpointReference callbackEndpoint =
new EndpointReferenceImpl((RuntimeComponent)refComponent, callbackService, callbackBinding,
callbackContract);
wireSource.setCallbackEndpoint(callbackEndpoint);
}
EndpointReference wireTarget =
new EndpointReferenceImpl((RuntimeComponent)serviceComponent, service, serviceBinding, bindingContract);
// TUSCANY-2029 - We should use the URI of the serviceBinding because the target may be a Component in a
// nested composite.
if (serviceBinding != null) {
wireTarget.setURI(serviceBinding.getURI());
}
RuntimeWire wire =
new RuntimeWireImpl(wireSource, wireTarget, interfaceContractMapper, workScheduler, wireProcessor,
messageFactory, conversationManager);