}
}
public <T> T resolveModel(Class<T> modelClass, T unresolved, ProcessorContext context) {
schemaCollection.setSchemaResolver(new URIResolverImpl(contribution, context));
XSDefinition definition = (XSDefinition)unresolved;
String namespace = definition.getNamespace();
XSDefinition resolved = null;
// Lookup a definition for the given namespace, within the contribution
List<XSDefinition> list = map.get(namespace);
if (list == null ||
(list != null && list.size() == 0)){
// if no schema is found locally delegate to other
// contributions via the imports
resolved = resolutionDelegation(namespace, context);
return modelClass.cast(resolved);
}
XSDefinition modelXSD = null;
if (list != null && definition.getDocument() != null) {
// Set the document for the inline schema
int index = list.indexOf(definition);
if (index != -1) { // a matching (not identical) document was found
modelXSD = list.get(index);
modelXSD.setDocument(definition.getDocument());
}
}
if (list == null && definition.getDocument() != null) {
// Hit for the 1st time
list = new ArrayList<XSDefinition>();
list.add(definition);
map.put(namespace, list);
}
try {
resolved = aggregate(list);
} catch (IOException e) {
throw new ContributionRuntimeException(e);
}
if (resolved != null && !resolved.isUnresolved()) {
if (definition.isUnresolved() && definition.getSchema() == null && modelXSD != null) {
// Update the unresolved model with schema information and mark it
// resolved. This information in the unresolved model is needed when
// this method is called by WSDLModelResolver.readInlineSchemas().
definition.setSchema(modelXSD.getSchema());
definition.setSchemaCollection(modelXSD.getSchemaCollection());
definition.setUnresolved(false);
}
return modelClass.cast(resolved);
}