for (ComponentService componentService : componentReference.getTargets()) {
// Resolve the target component and service
String name = componentService.getName();
ComponentService targetComponentService = componentServices.get(name);
Component targetComponent;
int s = name.indexOf('/');
if (s == -1) {
targetComponent = components.get(name);
} else {
targetComponent = components.get(name.substring(0, s));
}
if (targetComponentService != null) {
// Check that the target component service provides
// a superset of the component reference interface
if (componentReference.getInterfaceContract() == null ||
interfaceContractMapper.isCompatible(componentReference.getInterfaceContract(), targetComponentService.getInterfaceContract())) {
Target target = new Target(targetComponent, targetComponentService);
targets.add(target);
// mark the reference target as resolved. Used later when we are looking to
// see if an sca binding is associated with a resolved target or not
componentService.setUnresolved(false);
} else {
warning("Incompatible interfaces on component reference and target: " + componentReference
.getName()
+ " : "
+ componentService.getName(),
composite);
}
} else {
// add all the reference bindings into the target so that they
// can be used for comparison when the target is resolved at runtime
componentService.getBindings().addAll(componentReference.getBindings());
// The bindings will be cloned back into the reference when the
// target is finally resolved.
warning("Component reference target not found, it might be a remote service: " + componentService.getName(), composite);
}
}
} else if (componentReference.getReference() != null) {
// Resolve targets from the corresponding reference in the
// componentType
for (ComponentService componentService : componentReference.getReference().getTargets()) {
// Resolve the target component and service
String name = componentService.getName();
ComponentService targetComponentService = componentServices.get(name);
Component targetComponent;
int s = name.indexOf('/');
if (s == -1) {
targetComponent = components.get(name);
} else {
targetComponent = components.get(name.substring(0, s));