public Object removeModel(Object resolved, ProcessorContext context) {
return map.remove(((BPELProcessDefinition)resolved).getName());
}
public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
BPELProcessDefinition resolved = null;
QName qname = ((BPELProcessDefinition)unresolved).getName();
// Lookup a definition for the given namespace, from imports
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);
}
}
// Not found, Lookup a definition for the given namespace, within contribution
resolved = (BPELProcessDefinition) map.get(qname);
if(resolved.isUnresolved()) {
try {
resolve(resolved, context);
} catch(Exception e) {
//FIXME
}