throw new ServiceRuntimeException(e);
}
}
public void resolveEndpoint(Endpoint endpoint) {
CompositeContext compositeContext = ((RuntimeEndpoint)endpoint).getCompositeContext();
if (compositeContext == null){
// will be null if this is the SCAClient
return;
}
Definitions systemDefinitions = compositeContext.getSystemDefinitions();
if (systemDefinitions != null){
// Find pre-resolved intents from the system definition
List<Intent> intents = new ArrayList<Intent>();
for (Intent intent : endpoint.getRequiredIntents()){
Intent resolvedIntent = PolicyHelper.getIntent(systemDefinitions, intent.getName());
if (resolvedIntent != null){
intents.add(resolvedIntent);
} else {
// look to see if this intent is provided by the binding
BindingType bindingType = systemDefinitions.getBindingType(endpoint.getBinding().getType());
if (bindingType != null){
for (Intent apIntent : bindingType.getAlwaysProvidedIntents()){
if (apIntent.getName().equals(intent.getName())){
resolvedIntent = apIntent;
break;
}
}
if (resolvedIntent == null){
for (Intent mpIntent : bindingType.getMayProvidedIntents()){
if (mpIntent.getName().equals(intent.getName())){
resolvedIntent = mpIntent;
break;
}
}
}
}
if (resolvedIntent != null){
intents.add(resolvedIntent);
} else {
throw new ServiceRuntimeException("Remote endpoint " +
endpoint +
" has intent " +
intent +
" that can't be found in the local system definitions in node " +
compositeContext.getNodeURI());
}
}
}
endpoint.getRequiredIntents().clear();
endpoint.getRequiredIntents().addAll(intents);
// Find pre-resolved policy sets from the system definition
List<PolicySet> policySets = new ArrayList<PolicySet>();
for (PolicySet policySet : endpoint.getPolicySets()){
PolicySet resolvedPolicySet = PolicyHelper.getPolicySet(systemDefinitions, policySet.getName());
if (resolvedPolicySet != null){
policySets.add(resolvedPolicySet);
} else {
throw new ServiceRuntimeException("Remote endpoint " +
endpoint +
" has policy set " +
policySet +
" that can't be found in the local system definitions in node " +
compositeContext.getNodeURI());
}
}
endpoint.getPolicySets().clear();
endpoint.getPolicySets().addAll(policySets);