List<Service> compositeServices = composite.getServices();
for (Service service : compositeServices) {
// Create default SCA binding
if (service.getBindings().isEmpty()) {
SCABinding scaBinding = createSCABinding();
service.getBindings().add(scaBinding);
}
// Create default SCA callback binding
if (service.getInterfaceContract() != null
&& service.getInterfaceContract().getCallbackInterface() != null
&& service.getCallback() != null
&& service.getCallback().getBindings().isEmpty()) {
SCABinding scaBinding = createSCABinding();
scaBinding.setName(service.getName() + "Callback");
service.getCallback().getBindings().add(scaBinding);
}
// Initialize binding names and URIs
for (Binding binding : service.getBindings()) {
constructBindingName(service, binding);
constructBindingURI(parentComponentURI, composite, service, binding, defaultBindings);
}
}
// Initialize composite reference callback binding URIs
for (Reference reference : composite.getReferences()) {
// Create default SCA callback binding
if (reference.getInterfaceContract() != null
&& reference.getInterfaceContract().getCallbackInterface() != null
&& reference.getCallback() != null
&& reference.getCallback().getBindings().isEmpty()) {
SCABinding scaBinding = createSCABinding();
scaBinding.setName(reference.getName() + "Callback");
reference.getCallback().getBindings().add(scaBinding);
}
// Initialize binding names and URIs
if (reference.getCallback() != null) {
for (Binding binding : reference.getCallback().getBindings()) {
constructBindingName(reference, binding);
constructBindingURI(parentComponentURI, composite, reference, binding, defaultBindings);
}
}
}
// Initialize component service binding URIs
for (Component component : composite.getComponents()) {
// Index properties, services and references
Map<String, Service> services = new HashMap<String, Service>();
Map<String, Reference> references = new HashMap<String, Reference>();
Map<String, Property> properties = new HashMap<String, Property>();
indexImplementationPropertiesServicesAndReferences(component,
services,
references,
properties);
// Index component services, references and properties
// Also check for duplicates
Map<String, ComponentService> componentServices =
new HashMap<String, ComponentService>();
Map<String, ComponentReference> componentReferences =
new HashMap<String, ComponentReference>();
Map<String, ComponentProperty> componentProperties =
new HashMap<String, ComponentProperty>();
indexComponentPropertiesServicesAndReferences(component,
componentServices,
componentReferences,
componentProperties);
// Reconcile component services/references/properties and
// implementation services/references and create component
// services/references/properties for the services/references
// declared by the implementation
reconcileServices(component, services, componentServices);
reconcileReferences(component, references, componentReferences);
reconcileProperties(component, properties, componentProperties);
for (ComponentService service : component.getServices()) {
// Create default SCA binding
if (service.getBindings().isEmpty()) {
SCABinding scaBinding = createSCABinding();
service.getBindings().add(scaBinding);
}
// Create default SCA callback binding
if (service.getInterfaceContract() != null
&& service.getInterfaceContract().getCallbackInterface() != null
&& service.getCallback() != null
&& service.getCallback().getBindings().isEmpty()) {
SCABinding scaBinding = createSCABinding();
scaBinding.setName(service.getName() + "Callback");
service.getCallback().getBindings().add(scaBinding);
}
// Add all SCA bindings for the service callback to the bindingMap
// so that BindingConfigurationUtil.matchBinding() can identify the node
// for the target component.
if (service.getInterfaceContract() != null
&& service.getInterfaceContract().getCallbackInterface() != null
&& service.getCallback() != null
&& bindingMap != null
&& defaultBindings != null) {
for (Binding binding : service.getCallback().getBindings()) {
if (binding instanceof SCABinding) {
for (Binding nodeBinding : defaultBindings) {
if (nodeBinding instanceof SCABinding) {
bindingMap.put(binding, nodeBinding);
break;
}
}
}
}
}
// Initialize binding names and URIs
for (Binding binding : service.getBindings()) {
constructBindingName(service, binding);
constructBindingURI(component, service, binding, defaultBindings);
}
}
for (ComponentReference reference : component.getReferences()) {
// Create default SCA binding
if (reference.getBindings().isEmpty()) {
SCABinding scaBinding = createSCABinding();
reference.getBindings().add(scaBinding);
}
// Add all SCA bindings for the reference to the bindingMap so that
// BindingConfigurationUtil.matchBinding() can identify the node for
// the source component.
if (bindingMap != null && defaultBindings != null) {
for (Binding binding : reference.getBindings()) {
if (binding instanceof SCABinding) {
for (Binding nodeBinding : defaultBindings) {
if (nodeBinding instanceof SCABinding) {
bindingMap.put(binding, nodeBinding);
break;
}
}
}
}
}
// Create default SCA callback binding
if (reference.getInterfaceContract() != null
&& reference.getInterfaceContract().getCallbackInterface() != null
&& reference.getCallback() != null
&& reference.getCallback().getBindings().isEmpty()) {
SCABinding scaBinding = createSCABinding();
scaBinding.setName(reference.getName() + "Callback");
reference.getCallback().getBindings().add(scaBinding);
}
// Add all SCA bindings for the reference callback to the bindingMap
// so that BindingConfigurationUtil.matchBinding() can identify the node