return aggregated;
}
public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
WSDLDefinition resolved = null;
String namespace = ((WSDLDefinition)unresolved).getNamespace();
if (namespace == null) {
return modelClass.cast(unresolved);
}
// Lookup based on wsdli:location
if (((WSDLDefinition)unresolved).getWsdliLocations().containsKey(namespace)) {
try {
loadDefinition(((WSDLDefinition)unresolved), context);
} catch (ContributionReadException e) {
context.getMonitor().error(context.getMonitor(), this, "interface-wsdlxml-validation-messages", "wsdliLocationException", e, ((WSDLDefinition)unresolved).getNamespace());
}
return modelClass.cast((WSDLDefinition)unresolved);
}
// Lookup a definition for the given namespace, from imports
for (Import import_ : this.contribution.getImports()) {
if (import_ instanceof NamespaceImport) {
NamespaceImport namespaceImport = (NamespaceImport)import_;
if (namespaceImport.getNamespace().equals(namespace)) {
// Delegate the resolution to the namespace import resolver
resolved =
namespaceImport.getModelResolver().resolveModel(WSDLDefinition.class,
(WSDLDefinition)unresolved, context);
if (!resolved.isUnresolved()) {
return modelClass.cast(resolved);
}
}
} else if (import_ instanceof DefaultImport) {
// Delegate the resolution to the default import resolver
resolved =
import_.getModelResolver().resolveModel(WSDLDefinition.class,
(WSDLDefinition)unresolved, context);
if (!resolved.isUnresolved()) {
return modelClass.cast(resolved);
}
}
}
// Not found, lookup a definition for the given namespace, within contribution
List<WSDLDefinition> list = map.get(namespace);
try {
resolved = aggregate(list, context);
} catch (ContributionReadException e) {
throw new RuntimeException(e);
}
if (resolved != null && !resolved.isUnresolved()) {
// check that the WSDL we just found has the requisite
// port type, binding and/or service. If not return
// the input WSDL to force the resolution process to continue
WSDLDefinition inputWSDL = (WSDLDefinition)unresolved;
WSDLDefinition outputWSDL = (WSDLDefinition)resolved;
if (inputWSDL.getNameOfPortTypeToResolve() != null){
if (outputWSDL.getWSDLObject(PortType.class, inputWSDL.getNameOfPortTypeToResolve()) == null){
return modelClass.cast(unresolved);
}
}
if (inputWSDL.getNameOfBindingToResolve() != null){
if (outputWSDL.getWSDLObject(Binding.class, inputWSDL.getNameOfBindingToResolve()) == null){
return modelClass.cast(unresolved);
}
}
if (inputWSDL.getNameOfServiceToResolve() != null){
if (outputWSDL.getWSDLObject(Service.class, inputWSDL.getNameOfServiceToResolve()) == null){
return modelClass.cast(unresolved);
}
}
return modelClass.cast(resolved);