1616
1717package org .springframework .ws .soap .axiom ;
1818
19- import java .io .ByteArrayInputStream ;
20- import java .io .ByteArrayOutputStream ;
21- import java .io .OutputStream ;
22- import java .io .Writer ;
2319import javax .xml .stream .XMLStreamException ;
24- import javax .xml .stream .XMLStreamReader ;
2520import javax .xml .stream .XMLStreamWriter ;
2621
2722import org .apache .axiom .om .OMDataSource ;
28- import org .apache .axiom .om .OMOutputFormat ;
29- import org .apache .axiom .om .util .StAXUtils ;
23+ import org .apache .axiom .om .ds .AbstractPushOMDataSource ;
3024
3125import org .springframework .util .Assert ;
32- import org .springframework .util .StringUtils ;
3326import org .springframework .ws .stream .StreamingPayload ;
3427
3528/**
3831 * @author Arjen Poutsma
3932 * @since 2.0
4033 */
41- class StreamingOMDataSource implements OMDataSource {
34+ class StreamingOMDataSource extends AbstractPushOMDataSource {
4235
4336 private final StreamingPayload payload ;
4437
@@ -48,36 +41,13 @@ class StreamingOMDataSource implements OMDataSource {
4841 }
4942
5043 @ Override
51- public void serialize (OutputStream output , OMOutputFormat format ) throws XMLStreamException {
52- XMLStreamWriter streamWriter ;
53- if (format != null && StringUtils .hasLength (format .getCharSetEncoding ())) {
54- streamWriter = StAXUtils .createXMLStreamWriter (output , format .getCharSetEncoding ());
55- }
56- else {
57- streamWriter = StAXUtils .createXMLStreamWriter (output );
58- }
59- serialize (streamWriter );
60- }
61-
62- @ Override
63- public void serialize (Writer writer , OMOutputFormat format ) throws XMLStreamException {
64- XMLStreamWriter streamWriter = StAXUtils .createXMLStreamWriter (writer );
65- serialize (streamWriter );
44+ public boolean isDestructiveWrite () {
45+ return false ;
6646 }
6747
6848 @ Override
6949 public void serialize (XMLStreamWriter xmlWriter ) throws XMLStreamException {
7050 payload .writeTo (xmlWriter );
71- xmlWriter .flush ();
72- }
73-
74- @ Override
75- public XMLStreamReader getReader () throws XMLStreamException {
76- ByteArrayOutputStream bos = new ByteArrayOutputStream ();
77- serialize (bos , null );
78-
79- ByteArrayInputStream bis = new ByteArrayInputStream (bos .toByteArray ());
80- return StAXUtils .createXMLStreamReader (bis );
8151 }
8252
8353}
0 commit comments