use of com.sun.xml.ws.streaming.TidyXMLStreamReader in project metro-jax-ws by eclipse-ee4j.
the class SDDocumentSource method create.
/**
* Creates {@link SDDocumentSource} from resource path using resolvingClass to read the resource.
* Required for Jigsaw runtime.
*
* @param resolvingClass class used to read resource
* @param path resource path
*/
private static SDDocumentSource create(final String path, final Class<?> resolvingClass) {
return new SDDocumentSource() {
@Override
public XMLStreamReader read(XMLInputFactory xif) throws IOException, XMLStreamException {
InputStream is = inputStream();
return new TidyXMLStreamReader(xif.createXMLStreamReader(path, is), is);
}
@Override
public XMLStreamReader read() throws IOException, XMLStreamException {
InputStream is = inputStream();
return new TidyXMLStreamReader(XMLStreamReaderFactory.create(path, is, false), is);
}
@Override
public URL getSystemId() {
try {
return new URL("file://" + path);
} catch (MalformedURLException e) {
return null;
}
}
private InputStream inputStream() throws IOException {
java.lang.Module module = resolvingClass.getModule();
InputStream stream = module.getResourceAsStream(path);
if (stream != null) {
return stream;
}
throw new ServerRtException("cannot.load.wsdl", path);
}
};
}
use of com.sun.xml.ws.streaming.TidyXMLStreamReader in project metro-jax-ws by eclipse-ee4j.
the class StreamDecoderImpl method decode.
@Override
public Message decode(InputStream in, String charset, AttachmentSet att, SOAPVersion soapVersion) throws IOException {
XMLStreamReader reader = XMLStreamReaderFactory.create(null, in, charset, true);
reader = new TidyXMLStreamReader(reader, in);
return StreamSOAPCodec.decode(soapVersion, reader, att);
}
use of com.sun.xml.ws.streaming.TidyXMLStreamReader in project metro-jax-ws by eclipse-ee4j.
the class DeploymentDescriptorParser method parse.
/**
* Parses the {@code sun-jaxws.xml} file and configures
* a set of {@link HttpAdapter}s.
*/
@NotNull
public List<A> parse(String systemId, InputStream is) {
XMLStreamReader reader = null;
try {
reader = new TidyXMLStreamReader(XMLStreamReaderFactory.create(systemId, is, true), is);
XMLStreamReaderUtil.nextElementContent(reader);
return parseAdapters(reader);
} finally {
if (reader != null) {
try {
reader.close();
} catch (XMLStreamException e) {
throw new ServerRtException("runtime.parser.xmlReader", e);
}
}
try {
is.close();
} catch (IOException e) {
// ignore
}
}
}
use of com.sun.xml.ws.streaming.TidyXMLStreamReader 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);
}
use of com.sun.xml.ws.streaming.TidyXMLStreamReader in project metro-jax-ws by eclipse-ee4j.
the class EntityResolverWrapper method resolveEntity.
public Parser resolveEntity(String publicId, String systemId) throws SAXException, IOException {
InputSource source = core.resolveEntity(publicId, systemId);
if (source == null)
// default
return null;
// but if none is given, the system ID before the entity resolution is better than nothing.
if (source.getSystemId() != null)
systemId = source.getSystemId();
URL url = new URL(systemId);
InputStream stream;
if (useStreamFromEntityResolver) {
stream = source.getByteStream();
} else {
stream = url.openStream();
}
return new Parser(url, new TidyXMLStreamReader(XMLStreamReaderFactory.create(url.toExternalForm(), stream, true), stream));
}
Aggregations