protected void computePolicies(Composite composite, Definitions definitions, Monitor monitor) {
// compute policies recursively
for (Component component : composite.getComponents()) {
Implementation implementation = component.getImplementation();
if (implementation instanceof Composite) {
computePolicies((Composite)implementation, definitions, monitor);
}
}
for (Component component : composite.getComponents()) {
isMutualExclusive(component, component.getImplementation());
for (ComponentService componentService : component.getServices()) {
isMutualExclusive(componentService, componentService.getService());
if (componentService.getInterfaceContract() != null) {
isMutualExclusive(componentService.getInterfaceContract().getInterface(), componentService
.getService().getInterfaceContract().getInterface());
isMutualExclusive(componentService.getInterfaceContract().getCallbackInterface(), componentService
.getService().getInterfaceContract().getCallbackInterface());
}
for (Endpoint2 ep : componentService.getEndpoints()) {
// Inherit from the componentType.service.interface
if (componentService.getService() != null && componentService.getService().getInterfaceContract() != null) {
inherit(ep, componentService.getService().getInterfaceContract().getInterface());
}
if (componentService.getInterfaceContract() != null) {
// Inherit from the component.service.interface
inherit(ep, componentService.getInterfaceContract().getInterface());
}
// Inherit from the componentType/service
inheritFromService(ep, composite, component, componentService.getService());
// Find the corresponding binding in the componentType and inherit the intents/policySets
if (componentService.getService() != null) {
for (Binding binding : componentService.getService().getBindings()) {
if (isEqual(ep.getBinding().getName(), binding.getName()) && (binding instanceof PolicySubject)) {
isMutualExclusive((PolicySubject)ep.getBinding(), (PolicySubject)binding);
// Inherit from componentType.service.binding
inherit(ep, binding);
break;
}
}
}
// Inherit from composite/component/service
inheritFromService(ep, composite, ep.getComponent(), ep.getService());
// Inherit from binding
inherit(ep, ep.getBinding());
// Replace profile intents with their required intents
// Remove the intents whose @contraints do not include the current element
// Replace unqualified intents if there is a qualified intent in the list
// Replace qualifiable intents with the default qualied intent
resolveAndNormalize(ep, definitions, monitor);
}
}
for (ComponentReference componentReference : component.getReferences()) {
isMutualExclusive(componentReference, componentReference.getReference());
if (componentReference.getInterfaceContract() != null) {
isMutualExclusive(componentReference.getInterfaceContract().getInterface(), componentReference
.getReference().getInterfaceContract().getInterface());
isMutualExclusive(componentReference.getInterfaceContract().getCallbackInterface(),
componentReference.getReference().getInterfaceContract().getCallbackInterface());
}
for (EndpointReference2 epr : componentReference.getEndpointReferences()) {
// Inherit from the componentType.reference.interface
if (componentReference.getReference() != null && componentReference.getReference()
.getInterfaceContract() != null) {
inherit(epr, componentReference.getReference().getInterfaceContract().getInterface());
}
// Inherit from the component.reference.interface
if (componentReference.getInterfaceContract() != null) {
inherit(epr, componentReference.getInterfaceContract().getInterface());
}
// Inherit from the componentType/reference
inheritFromReference(epr, composite, component, componentReference.getReference());
// Find the corresponding binding in the componentType and inherit the intents/policySets
if (componentReference.getReference() != null) {
for (Binding binding : componentReference.getReference().getBindings()) {
if (epr.getBinding() != null && isEqual(epr.getBinding().getName(), binding.getName())
&& (binding instanceof PolicySubject)) {
isMutualExclusive((PolicySubject)epr.getBinding(), (PolicySubject)binding);
// Inherit from componentType.reference.binding
inherit(epr, binding);
break;
}
}
}
// Inherit from composite/component/reference/binding
inheritFromReference(epr, composite, epr.getComponent(), epr.getReference());
inherit(epr, epr.getBinding());
// Replace profile intents with their required intents
// Remove the intents whose @contraints do not include the current element
// Replace unqualified intents if there is a qualified intent in the list
// Replace qualifiable intents with the default qualied intent
resolveAndNormalize(epr, definitions, monitor);
}
}
Implementation implementation = component.getImplementation();
// How to deal with implementation level policySets/intents
}
}