// Process the component services declared on components in this composite
for (ComponentService componentService : component.getServices()) {
Service implService = componentService.getService();
if (implService != null && implService instanceof CompositeService) {
CompositeService compositeService = (CompositeService)implService;
// Get the next lower level promoted service
ComponentService promotedService = compositeService.getPromotedService();
if (promotedService != null) {
// Set the bindings using the top level bindings to override the lower level bindings
if (!bindingsSpecifiedManually(compositeService.getBindings()) &&
bindingsSpecifiedManually(promotedService.getBindings()) ) {
compositeService.getBindings().clear();
for (Binding binding : promotedService.getBindings()) {
try {
compositeService.getBindings().add((Binding)binding.clone());
} catch (CloneNotSupportedException ex) {
// this binding can't be used in the promoted service
}
}
}
if (!bindingsSpecifiedManually(componentService.getBindings()) &&
bindingsSpecifiedManually(compositeService.getBindings()) ) {
componentService.getBindings().clear();
componentService.getBindings().addAll(compositeService.getBindings());
}
if (componentService.getInterfaceContract() != null &&
componentService.getInterfaceContract().getCallbackInterface() != null) {
if (!(compositeService.getCallback() != null &&
bindingsSpecifiedManually(compositeService.getCallback().getBindings())) &&
promotedService.getCallback() != null &&
bindingsSpecifiedManually(promotedService.getCallback().getBindings())) {
if (compositeService.getCallback() != null) {
compositeService.getCallback().getBindings().clear();
} else {
compositeService.setCallback(assemblyFactory.createCallback());
}
for (Binding binding : promotedService.getCallback().getBindings()) {
try {
compositeService.getCallback().getBindings().add((Binding)binding.clone());
} catch (CloneNotSupportedException ex) {
// this binding can't be used in the promoted service
}
}
}
if (!(componentService.getCallback() != null &&
bindingsSpecifiedManually(componentService.getCallback().getBindings())) &&
compositeService.getCallback() != null &&
bindingsSpecifiedManually(compositeService.getCallback().getBindings())) {
if (componentService.getCallback() != null) {
componentService.getCallback().getBindings().clear();
} else {
componentService.setCallback(assemblyFactory.createCallback());
}
componentService.getCallback().getBindings().addAll(
compositeService.getCallback().getBindings());
}
}
}
}
}