use of com.sun.xml.ws.api.WSDLLocator in project metro-jax-ws by eclipse-ee4j.
the class RuntimeWSDLParser method createReader.
/**
* Make sure to return a "fresh" reader each time it is called because
* more than one active reader may be needed within a single thread
* to parse a WSDL file.
*/
private static XMLStreamReader createReader(URL wsdlLoc, Class<Service> serviceClass) throws IOException, XMLStreamException {
InputStream stream;
try {
stream = wsdlLoc.openStream();
} catch (IOException io) {
out: do {
if (serviceClass != null) {
WSDLLocator locator = ContainerResolver.getInstance().getContainer().getSPI(WSDLLocator.class);
if (locator != null) {
String exForm = wsdlLoc.toExternalForm();
URL ru = serviceClass.getResource(".");
String loc = wsdlLoc.getPath();
if (ru != null) {
String ruExForm = ru.toExternalForm();
if (exForm.startsWith(ruExForm)) {
loc = exForm.substring(ruExForm.length());
}
}
wsdlLoc = locator.locateWSDL(serviceClass, loc);
if (wsdlLoc != null) {
stream = new FilterInputStream(wsdlLoc.openStream()) {
boolean closed;
@Override
public void close() throws IOException {
if (!closed) {
closed = true;
byte[] buf = new byte[8192];
while (read(buf) != -1) ;
super.close();
}
}
};
break out;
}
}
}
throw io;
} while (true);
}
return new TidyXMLStreamReader(XMLStreamReaderFactory.create(wsdlLoc.toExternalForm(), stream, false), stream);
}
Aggregations