< prev index next >

jaxws/src/java.xml.ws/share/classes/com/sun/xml/internal/ws/api/server/SDDocumentSource.java

Print this page

        

*** 1,7 **** /* ! * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 24,36 **** */ package com.sun.xml.internal.ws.api.server; import com.sun.xml.internal.stream.buffer.XMLStreamBuffer; import com.sun.xml.internal.ws.server.ServerRtException; import com.sun.xml.internal.ws.streaming.TidyXMLStreamReader; - import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import java.io.IOException; --- 24,36 ---- */ package com.sun.xml.internal.ws.api.server; import com.sun.xml.internal.stream.buffer.XMLStreamBuffer; + import com.sun.xml.internal.ws.api.streaming.XMLStreamReaderFactory; import com.sun.xml.internal.ws.server.ServerRtException; import com.sun.xml.internal.ws.streaming.TidyXMLStreamReader; import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamReader; import java.io.IOException;
*** 40,50 **** /** * SPI that provides the source of {@link SDDocument}. * * <p> ! * This abstract class could be implemented by appliations, or one of the * {@link #create} methods can be used. * * @author Kohsuke Kawaguchi */ public abstract class SDDocumentSource { --- 40,50 ---- /** * SPI that provides the source of {@link SDDocument}. * * <p> ! * This abstract class could be implemented by applications, or one of the * {@link #create} methods can be used. * * @author Kohsuke Kawaguchi */ public abstract class SDDocumentSource {
*** 83,114 **** --- 83,124 ---- */ public abstract XMLStreamReader read() throws IOException, XMLStreamException; /** * System ID of this document. + * @return */ public abstract URL getSystemId(); + public static SDDocumentSource create(final Class<?> implClass, final String url) { + return create(url, implClass); + } + /** * Creates {@link SDDocumentSource} from an URL. + * @param url + * @return */ public static SDDocumentSource create(final URL url) { return new SDDocumentSource() { private final URL systemId = url; + @Override public XMLStreamReader read(XMLInputFactory xif) throws IOException, XMLStreamException { InputStream is = url.openStream(); return new TidyXMLStreamReader( xif.createXMLStreamReader(systemId.toExternalForm(),is), is); } + @Override public XMLStreamReader read() throws IOException, XMLStreamException { InputStream is = url.openStream(); return new TidyXMLStreamReader( XMLStreamReaderFactory.create(systemId.toExternalForm(),is,false), is); } + @Override public URL getSystemId() { return systemId; } }; }
*** 118,140 **** * Required for Jigsaw runtime. * * @param resolvingClass class used to read resource * @param path resource path */ ! public static SDDocumentSource create(final Class resolvingClass, final String path) { return new SDDocumentSource() { public XMLStreamReader read(XMLInputFactory xif) throws IOException, XMLStreamException { InputStream is = inputStream(); return new TidyXMLStreamReader(xif.createXMLStreamReader(path,is), is); } public XMLStreamReader read() throws IOException, XMLStreamException { InputStream is = inputStream(); return new TidyXMLStreamReader(XMLStreamReaderFactory.create(path,is,false), is); } public URL getSystemId() { try { return new URL("file://" + path); } catch (MalformedURLException e) { return null; --- 128,153 ---- * 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;
*** 155,175 **** --- 168,194 ---- }; } /** * Creates a {@link SDDocumentSource} from {@link XMLStreamBuffer}. + * @param systemId + * @param xsb + * @return */ public static SDDocumentSource create(final URL systemId, final XMLStreamBuffer xsb) { return new SDDocumentSource() { + @Override public XMLStreamReader read(XMLInputFactory xif) throws XMLStreamException { return xsb.readAsXMLStreamReader(); } + @Override public XMLStreamReader read() throws XMLStreamException { return xsb.readAsXMLStreamReader(); } + @Override public URL getSystemId() { return systemId; } }; }
< prev index next >