if ( targetService.isUnresolved()){
if (service != null){
// Find the binding already in use for this target
Binding binding = null;
for (Binding tmpBinding : reference.getBindings()){
if ((tmpBinding.getName() != null) &&
(tmpBinding.getName().startsWith(reference.getName() + "#" + targetName))){
binding = tmpBinding;
}
}
// Resolve the binding that should be used for this target
// TODO - hang onto the old bindings at the domain level, i.e.
// don't rely on the target objects as we still need the
// bindings if we are going to do autowiring
List<Binding> source = targetService.getBindings();
List<Binding> target = service.getBindings();
Binding newBinding = BindingUtil.matchBinding(serviceComponent, (ComponentService)service, source, target);
// update the existing binding to the new binding if required
if (newBinding != null) {
if (binding != null){
// there is a binding already so see if the URI has changed
if ((binding.getURI() == null) ||
(!binding.getURI().equals(newBinding.getURI()))){
binding.setURI(newBinding.getURI());
compositeChanged = true;
}
} else {
// this is a newly configured binding so add it
reference.getBindings().add(newBinding);