}
}
}
private void addReferenceWire(Component component, ComponentReference reference, EndpointReference2 endpointReference) {
RuntimeComponentReference runtimeRef = (RuntimeComponentReference)reference;
// Use the interface contract of the reference on the component type and if there
// isn't one then use the one from the reference itself
Reference componentTypeRef = reference.getReference();
InterfaceContract sourceContract;
if (componentTypeRef == null || componentTypeRef.getInterfaceContract() == null) {
sourceContract = reference.getInterfaceContract();
} else {
sourceContract = componentTypeRef.getInterfaceContract();
}
// TODO - EPR - interface contract seems to be null in the implementation.web
// case. Not introspecting the CT properly?
if (sourceContract == null){
// take the contract from the service to which the reference is connected
sourceContract = endpointReference.getTargetEndpoint().getInterfaceContract();
reference.setInterfaceContract(sourceContract);
}
endpointReference.setInterfaceContract(sourceContract.makeUnidirectional(false));
/* TODO - EPR should have been done previously during matching
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);
}
*/
InterfaceContract bindingContract = getInterfaceContract(reference, endpointReference.getBinding());
Endpoint2 endpoint = endpointReference.getTargetEndpoint();
endpoint.setInterfaceContract(bindingContract);
/* TODO - EPR review in the light of new matching code
// 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());
}
*/
// create the wire
RuntimeWire wire = new RuntimeWireImpl2(true,
endpointReference,
endpoint,
interfaceContractMapper,
workScheduler,
wireProcessor,
messageFactory,
conversationManager);
runtimeRef.getRuntimeWires().add(wire);
}