final org.apache.tuscany.sca.contribution.Contribution contribution = contributionFactory.createContribution();
ProcessorContext processorContext = new ProcessorContext();
ExtensibleModelResolver extensibleResolver = new ExtensibleModelResolver(contribution, registry.getExtensionPoint(ModelResolverExtensionPoint.class), modelFactories);
ModelResolver wsdlResolver = (ModelResolver)extensibleResolver.getModelResolverInstance(WSDLDefinition.class);
XSDModelResolver xsdResolver = (XSDModelResolver)extensibleResolver.getModelResolverInstance(XSDefinition.class);
contribution.setURI("temp");
contribution.setLocation(topWSDLLocation);
contribution.setModelResolver(extensibleResolver);
// read
for (XMLString xmlString : xmlMap.values()){
if (xmlString instanceof WSDLInfo){
WSDLReader reader;
try {
reader = AccessController.doPrivileged(new PrivilegedExceptionAction<WSDLReader>() {
public WSDLReader run() throws WSDLException {
return javax.wsdl.factory.WSDLFactory.newInstance().newWSDLReader();
}
});
} catch (PrivilegedActionException e){
throw (WSDLException)e.getException();
}
reader.setFeature("javax.wsdl.verbose", false);
reader.setFeature("javax.wsdl.importDocuments", true);
final WSDLLocatorImpl locator = new WSDLLocatorImpl(xmlString.getBaseURI(), xmlMap);
final WSDLReader freader = reader;
Definition readDefinition;
try {
readDefinition = AccessController.doPrivileged(new PrivilegedExceptionAction<Definition>() {
public Definition run() throws WSDLException {
return freader.readWSDL(locator);
}
});
} catch (PrivilegedActionException e){
throw (WSDLException)e.getException();
}
WSDLDefinition wsdlDefinition = wsdlFactory.createWSDLDefinition();
wsdlDefinition.setDefinition(readDefinition);
wsdlDefinition.setLocation(new URI(xmlString.getBaseURI()));
((WSDLInfo)xmlString).setWsdlDefintion(wsdlDefinition);
wsdlResolver.addModel(wsdlDefinition, processorContext);
} else {
InputStream inputStream = new ByteArrayInputStream(xmlString.getXmlString().getBytes());
InputSource inputSource = new InputSource(inputStream);
inputSource.setSystemId(xmlString.getBaseURI());
XmlSchema schema = schemaCollection.read(inputSource, null);
inputStream.close();
XSDefinition xsdDefinition = xsdFactory.createXSDefinition();
xsdDefinition.setSchema(schema);
((XSDInfo)xmlString).setXsdDefinition(xsdDefinition);
xsdResolver.addModel(xsdDefinition, processorContext);
}
}
// resolve
for (XMLString xmlString : xmlMap.values()){