author | mkos |
Mon, 31 Mar 2014 10:43:20 +0200 | |
changeset 23782 | 953bfc3fbe31 |
parent 16791 | fe5141eabb0e |
permissions | -rw-r--r-- |
12009 | 1 |
/* |
23782
953bfc3fbe31
8036030: Update JAX-WS RI integration to latest version
mkos
parents:
16791
diff
changeset
|
2 |
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. |
12009 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package com.sun.xml.internal.ws.message.source; |
|
27 |
||
28 |
import com.sun.xml.internal.bind.api.Bridge; |
|
29 |
import com.sun.xml.internal.ws.api.SOAPVersion; |
|
30 |
import com.sun.xml.internal.ws.api.pipe.Codecs; |
|
31 |
import com.sun.xml.internal.ws.api.pipe.StreamSOAPCodec; |
|
32 |
import com.sun.xml.internal.ws.api.message.Message; |
|
16791 | 33 |
import com.sun.xml.internal.ws.api.message.MessageHeaders; |
12009 | 34 |
import com.sun.xml.internal.ws.api.message.Packet; |
35 |
import com.sun.xml.internal.ws.spi.db.XMLBridge; |
|
36 |
import com.sun.xml.internal.ws.streaming.SourceReaderFactory; |
|
37 |
import javax.xml.bind.JAXBException; |
|
38 |
import javax.xml.bind.Unmarshaller; |
|
39 |
import javax.xml.soap.SOAPException; |
|
40 |
import javax.xml.soap.SOAPMessage; |
|
41 |
import org.xml.sax.ContentHandler; |
|
42 |
import org.xml.sax.ErrorHandler; |
|
43 |
import org.xml.sax.SAXException; |
|
44 |
||
45 |
import javax.xml.stream.XMLStreamException; |
|
46 |
import javax.xml.stream.XMLStreamReader; |
|
47 |
import javax.xml.stream.XMLStreamWriter; |
|
48 |
import javax.xml.transform.Source; |
|
49 |
||
50 |
/** |
|
51 |
* Implementation of {@link Message} backed by {@link Source} where the Source |
|
52 |
* represents the complete message such as a SOAP envelope. It uses |
|
53 |
* {@link StreamSOAPCodec} to create a {@link Message} and uses it as a |
|
54 |
* delegate for all the methods. |
|
55 |
* |
|
56 |
* @author Vivek Pandey |
|
57 |
* @author Jitendra Kotamraju |
|
58 |
*/ |
|
59 |
public class ProtocolSourceMessage extends Message { |
|
60 |
private final Message sm; |
|
61 |
||
62 |
public ProtocolSourceMessage(Source source, SOAPVersion soapVersion) { |
|
63 |
XMLStreamReader reader = SourceReaderFactory.createSourceReader(source, true); |
|
64 |
com.sun.xml.internal.ws.api.pipe.StreamSOAPCodec codec = Codecs.createSOAPEnvelopeXmlCodec(soapVersion); |
|
65 |
sm = codec.decode(reader); |
|
66 |
} |
|
67 |
||
68 |
public boolean hasHeaders() { |
|
69 |
return sm.hasHeaders(); |
|
70 |
} |
|
71 |
||
72 |
public String getPayloadLocalPart() { |
|
73 |
return sm.getPayloadLocalPart(); |
|
74 |
} |
|
75 |
||
76 |
public String getPayloadNamespaceURI() { |
|
77 |
return sm.getPayloadNamespaceURI(); |
|
78 |
} |
|
79 |
||
80 |
public boolean hasPayload() { |
|
81 |
return sm.hasPayload(); |
|
82 |
} |
|
83 |
||
84 |
public Source readPayloadAsSource() { |
|
85 |
return sm.readPayloadAsSource(); |
|
86 |
} |
|
87 |
||
88 |
public XMLStreamReader readPayload() throws XMLStreamException { |
|
89 |
return sm.readPayload(); |
|
90 |
} |
|
91 |
||
92 |
public void writePayloadTo(XMLStreamWriter sw) throws XMLStreamException { |
|
93 |
sm.writePayloadTo(sw); |
|
94 |
} |
|
95 |
||
96 |
public void writeTo(XMLStreamWriter sw) throws XMLStreamException { |
|
97 |
sm.writeTo(sw); |
|
98 |
} |
|
99 |
||
100 |
public Message copy() { |
|
23782
953bfc3fbe31
8036030: Update JAX-WS RI integration to latest version
mkos
parents:
16791
diff
changeset
|
101 |
return sm.copy().copyFrom(sm); |
12009 | 102 |
} |
103 |
||
104 |
public Source readEnvelopeAsSource() { |
|
105 |
return sm.readEnvelopeAsSource(); |
|
106 |
} |
|
107 |
||
108 |
public SOAPMessage readAsSOAPMessage() throws SOAPException { |
|
109 |
return sm.readAsSOAPMessage(); |
|
110 |
} |
|
111 |
||
112 |
public SOAPMessage readAsSOAPMessage(Packet packet, boolean inbound) throws SOAPException { |
|
113 |
return sm.readAsSOAPMessage(packet, inbound); |
|
114 |
} |
|
115 |
||
116 |
public <T> T readPayloadAsJAXB(Unmarshaller unmarshaller) throws JAXBException { |
|
117 |
return (T)sm.readPayloadAsJAXB(unmarshaller); |
|
118 |
} |
|
119 |
/** @deprecated */ |
|
120 |
public <T> T readPayloadAsJAXB(Bridge<T> bridge) throws JAXBException { |
|
121 |
return sm.readPayloadAsJAXB(bridge); |
|
122 |
} |
|
123 |
public <T> T readPayloadAsJAXB(XMLBridge<T> bridge) throws JAXBException { |
|
124 |
return sm.readPayloadAsJAXB(bridge); |
|
125 |
} |
|
126 |
||
127 |
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException { |
|
128 |
sm.writeTo(contentHandler, errorHandler); |
|
129 |
} |
|
16791 | 130 |
|
131 |
public SOAPVersion getSOAPVersion() { |
|
132 |
return sm.getSOAPVersion(); |
|
133 |
} |
|
134 |
||
135 |
@Override |
|
136 |
public MessageHeaders getHeaders() { |
|
137 |
return sm.getHeaders(); |
|
138 |
} |
|
12009 | 139 |
} |