}
public void determineApplicableBindingPolicySets(Contract source, Contract target) throws PolicyComputationException {
for (Binding aBinding : source.getBindings()) {
if (aBinding instanceof PolicySetAttachPoint) {
PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)aBinding;
IntentAttachPointType bindingType = policiedBinding.getType();
// add the target component's intents to the reference binding
if (target != null) {
for (Intent intent : target.getRequiredIntents()) {
if (!policiedBinding.getRequiredIntents().contains(intent)) {
for (QName constrained : intent.getConstrains()) {
if (bindingType != null && bindingType.getName().getNamespaceURI()
.equals(constrained.getNamespaceURI())
&& bindingType.getName().getLocalPart().startsWith(constrained
.getLocalPart())) {
policiedBinding.getRequiredIntents().add(intent);
break;
}
}
}
}
}
//trim intents specified in operations. First check for policysets specified on the operation
//and then in the parent implementation
if ( aBinding instanceof OperationsConfigurator ) {
OperationsConfigurator opConfigurator = (OperationsConfigurator)aBinding;
for ( ConfiguredOperation confOp : opConfigurator.getConfiguredOperations() ) {
trimProvidedIntents(confOp.getRequiredIntents(), confOp.getPolicySets());
trimProvidedIntents(confOp.getRequiredIntents(), policiedBinding.getPolicySets());
}
}
trimProvidedIntents(policiedBinding.getRequiredIntents(), policiedBinding
.getPolicySets());
// determine additional policysets that match remaining intents
// TODO: resolved to domain policy registry and attach suitable
// policy sets to the binding