for (ComponentService target : componentReference.getTargets()) {
if (target.getService() instanceof CompositeService) {
// Wire to the actual component service
// promoted by a composite service
CompositeService compositeService = (CompositeService)target.getService();
// Find the promoted component service
ComponentService componentService = CompositeConfigurationBuilderImpl.getPromotedComponentService(compositeService);
if (componentService != null) {
promotedReference.getTargets().add(componentService);
}
} else {
// Wire to a non-composite target service
promotedReference.getTargets().add(target);
}
}
}
}
}
} else {
for (ComponentReference componentReference : component.getReferences()) {
// Wire the component reference to the actual
// non-composite component services
List<ComponentService> targets = componentReference.getTargets();
for (int i = 0, n = targets.size(); i < n; i++) {
ComponentService target = targets.get(i);
if (target.getService() instanceof CompositeService) {
// Wire to the actual component service
// promoted by a composite service
CompositeService compositeService = (CompositeService)target.getService();
ComponentService componentService = compositeService.getPromotedService();
if (componentService != null) {
targets.set(i, componentService);
}
}
}