List<String> locations = new ArrayList<String>();
// Collection of namespace imports with location
Map<String, NamespaceImport> locationMap = new HashMap<String, NamespaceImport>();
for (Import import_ : this.contribution.getImports()) {
if (import_ instanceof NamespaceImport) {
NamespaceImport namespaceImport = (NamespaceImport)import_;
if (namespaceImport.getNamespace().equals(qname.getNamespaceURI())) {
if (namespaceImport.getLocation() == null) {
// Delegate the resolution to the import resolver
resolved = namespaceImport.getModelResolver().resolveModel(BPELProcessDefinition.class, (BPELProcessDefinition)unresolved, context);
if (!resolved.isUnresolved()) {
return modelClass.cast(resolved);
}
} else {
// We might have multiple imports for the same namespace,
// need to search them in lexical order.
locations.add(namespaceImport.getLocation());
}
}
}
}
// Search namespace imports with locations in lexical order
Collections.sort(locations);
for (String location : locations) {
NamespaceImport namespaceImport = (NamespaceImport)locationMap.get(location);
// Delegate the resolution to the namespace import resolver
resolved = namespaceImport.getModelResolver().resolveModel(BPELProcessDefinition.class, (BPELProcessDefinition)unresolved, context);
if (!resolved.isUnresolved()) {
return modelClass.cast(resolved);
}
}