Class VerifiedStreamMessage
- java.lang.Object
-
- com.sun.xml.ws.api.message.Message
-
- com.sun.xml.ws.message.AbstractMessageImpl
-
- com.sun.xml.ws.security.opt.impl.incoming.VerifiedStreamMessage
-
public final class VerifiedStreamMessage extends AbstractMessageImpl
Message
implementation backed byXMLStreamReader
. TODO: we need another message class that keepsXMLStreamReader
that points at the start of the envelope element.
-
-
Field Summary
-
Fields inherited from class com.sun.xml.ws.message.AbstractMessageImpl
EMPTY_ATTS, NULL_LOCATOR, soapVersion
-
Fields inherited from class com.sun.xml.ws.api.message.Message
attachmentSet
-
-
Constructor Summary
Constructors Constructor Description VerifiedStreamMessage(MessageHeaders headers, AttachmentSet attachmentSet, XMLStreamReader reader, SOAPVersion soapVersion, Map<String,String> bodyEnvNs)
Creates aStreamMessage
from aXMLStreamReader
that points at the start element of the payload, and headers.VerifiedStreamMessage(TagInfoset envelopeTag, TagInfoset headerTag, AttachmentSet attachmentSet, MessageHeaders headers, TagInfoset bodyTag, XMLStreamReader reader, SOAPVersion soapVersion, Map<String,String> bodyEnvNs)
Creates aStreamMessage
from aXMLStreamReader
and the complete infoset of the SOAP envelope.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
consume()
Marks the message as consumed, without actually reading the contents.Message
copy()
Creates a copy of aMessage
.AttachmentSet
getAttachments()
Gets the attachments of this message (attachments live outside a message.)HeaderList
getHeaders()
Gets all the headers of this message.String
getPayloadLocalPart()
Gets the local name of the payload element.String
getPayloadNamespaceURI()
Gets the namespace URI of the payload element.boolean
hasHeaders()
Returns true if headers are present in the message.boolean
hasPayload()
Returns true if aMessage
has a payload.jakarta.xml.soap.SOAPMessage
readAsSOAPMessage()
Default implementation that usesAbstractMessageImpl.writeTo(ContentHandler, ErrorHandler)
XMLStreamReader
readPayload()
Reads the payload as aXMLStreamReader
This consumes the message.<T> T
readPayloadAsJAXB(XMLBridge<T> bridge)
Reads the payload as a Data-Bond object This consumes the message.<T> T
readPayloadAsJAXB(jakarta.xml.bind.Unmarshaller unmarshaller)
Reads the payload as a JAXB object by using the given unmarshaller.<T> T
readPayloadAsJAXB(org.glassfish.jaxb.runtime.api.Bridge<T> bridge)
Reads the payload as a JAXB object according to the givenBridge
.Source
readPayloadAsSource()
Returns the payload as aSource
object.void
writePayloadTo(XMLStreamWriter writer)
Writes the payload to StAX.void
writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment)
Writes the payload to SAX events.void
writeTo(XMLStreamWriter sw)
Default implementation that relies onMessage.writePayloadTo(XMLStreamWriter)
void
writeTo(ContentHandler contentHandler, ErrorHandler errorHandler)
Writes the whole envelope as SAX events.-
Methods inherited from class com.sun.xml.ws.message.AbstractMessageImpl
getSOAPVersion, readAsSOAPMessage, readEnvelopeAsSource, toSAAJ, writeToBodyStart
-
Methods inherited from class com.sun.xml.ws.api.message.Message
addSOAPMimeHeaders, assertOneWay, copyFrom, generateMessageID, getFirstDetailEntryName, getID, getID, getMethod, getOperation, getOperation, getTransportHeaders, getTransportHeaders, hasAttachments, isFault, isOneWay, setMessageMedadata
-
-
-
-
Constructor Detail
-
VerifiedStreamMessage
public VerifiedStreamMessage(@Nullable MessageHeaders headers, @NotNull AttachmentSet attachmentSet, @NotNull XMLStreamReader reader, @NotNull SOAPVersion soapVersion, Map<String,String> bodyEnvNs)
Creates aStreamMessage
from aXMLStreamReader
that points at the start element of the payload, and headers.This method creaets a
Message
from a payload.- Parameters:
headers
- if null, it means no headers. if non-null, it will be owned by this message.reader
- points at the start element/document of the payload (or the end element of the <s:Body> if there's no payload)
-
VerifiedStreamMessage
public VerifiedStreamMessage(@NotNull TagInfoset envelopeTag, @Nullable TagInfoset headerTag, @NotNull AttachmentSet attachmentSet, @Nullable MessageHeaders headers, @NotNull TagInfoset bodyTag, @NotNull XMLStreamReader reader, @NotNull SOAPVersion soapVersion, Map<String,String> bodyEnvNs)
Creates aStreamMessage
from aXMLStreamReader
and the complete infoset of the SOAP envelope.See #StreamMessage(MessageHeaders, AttachmentSet, XMLStreamReader, SOAPVersion) for the description of the basic parameters.
- Parameters:
headerTag
- Null if the message didn't have a header tag.
-
-
Method Detail
-
hasHeaders
public boolean hasHeaders()
Description copied from class:Message
Returns true if headers are present in the message.- Specified by:
hasHeaders
in classMessage
- Returns:
- true if headers are present.
-
getHeaders
public HeaderList getHeaders()
Description copied from class:Message
Gets all the headers of this message.Implementation Note
Message
implementation is allowed to defer the construction ofMessageHeaders
object. So if you only want to check for the existence of any header element, useMessage.hasHeaders()
.- Specified by:
getHeaders
in classMessage
- Returns:
- always return the same non-null object.
-
getAttachments
@NotNull public AttachmentSet getAttachments()
Description copied from class:Message
Gets the attachments of this message (attachments live outside a message.)- Overrides:
getAttachments
in classMessage
-
getPayloadLocalPart
public String getPayloadLocalPart()
Description copied from class:Message
Gets the local name of the payload element.- Specified by:
getPayloadLocalPart
in classMessage
- Returns:
- null if a
Message
doesn't have any payload.
-
getPayloadNamespaceURI
public String getPayloadNamespaceURI()
Description copied from class:Message
Gets the namespace URI of the payload element.- Specified by:
getPayloadNamespaceURI
in classMessage
- Returns:
- null if a
Message
doesn't have any payload.
-
hasPayload
public boolean hasPayload()
Description copied from class:Message
Returns true if aMessage
has a payload.A message without a payload is a SOAP message that looks like:
<S:Envelope> <S:Header> ... </S:Header> <S:Body /> </S:Envelope>
- Specified by:
hasPayload
in classMessage
-
readPayloadAsSource
public Source readPayloadAsSource()
Description copied from class:Message
Returns the payload as aSource
object. This consumes the message.- Specified by:
readPayloadAsSource
in classMessage
- Returns:
- if there's no payload, this method returns null.
-
readPayloadAsJAXB
public <T> T readPayloadAsJAXB(jakarta.xml.bind.Unmarshaller unmarshaller) throws jakarta.xml.bind.JAXBException
Description copied from class:Message
Reads the payload as a JAXB object by using the given unmarshaller. This consumes the message.- Overrides:
readPayloadAsJAXB
in classAbstractMessageImpl
- Throws:
jakarta.xml.bind.JAXBException
- If JAXB reports an error during the processing.
-
readPayloadAsJAXB
public <T> T readPayloadAsJAXB(org.glassfish.jaxb.runtime.api.Bridge<T> bridge) throws jakarta.xml.bind.JAXBException
Description copied from class:Message
Reads the payload as a JAXB object according to the givenBridge
. This consumes the message.- Overrides:
readPayloadAsJAXB
in classAbstractMessageImpl
- Returns:
- null if there's no payload.
- Throws:
jakarta.xml.bind.JAXBException
- If JAXB reports an error during the processing.
-
readPayloadAsJAXB
public <T> T readPayloadAsJAXB(XMLBridge<T> bridge) throws jakarta.xml.bind.JAXBException
Description copied from class:Message
Reads the payload as a Data-Bond object This consumes the message.- Overrides:
readPayloadAsJAXB
in classAbstractMessageImpl
- Returns:
- null if there's no payload.
- Throws:
jakarta.xml.bind.JAXBException
- If JAXB reports an error during the processing.
-
consume
public void consume()
Description copied from class:Message
Marks the message as consumed, without actually reading the contents.This method provides an opportunity for implementations to reuse any reusable resources needed for representing the payload.
This method may not be called more than once since it may have released the reusable resources.
-
readPayload
public XMLStreamReader readPayload()
Description copied from class:Message
Reads the payload as aXMLStreamReader
This consumes the message. The caller is encouraged to callXMLStreamReaderFactory.recycle(XMLStreamReader)
when finished using the instance.- Specified by:
readPayload
in classMessage
- Returns:
- If there's no payload, this method returns null.
Otherwise always non-null valid
XMLStreamReader
that points to the payload tag name.
-
writePayloadTo
public void writePayloadTo(XMLStreamWriter writer) throws XMLStreamException
Description copied from class:Message
Writes the payload to StAX. This method writes just the payload of the message to the writer. This consumes the message. The implementation will not writeXMLStreamWriter.writeStartDocument()
norXMLStreamWriter.writeEndDocument()
If there's no payload, this method is no-op.
- Specified by:
writePayloadTo
in classMessage
- Throws:
XMLStreamException
- If theXMLStreamWriter
reports an error, or some other errors happen during the processing.
-
writeTo
public void writeTo(XMLStreamWriter sw) throws XMLStreamException
Description copied from class:AbstractMessageImpl
Default implementation that relies onMessage.writePayloadTo(XMLStreamWriter)
- Overrides:
writeTo
in classAbstractMessageImpl
- Throws:
XMLStreamException
- If theXMLStreamWriter
reports an error, or some other errors happen during the processing.
-
writePayloadTo
public void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment) throws SAXException
Description copied from class:AbstractMessageImpl
Writes the payload to SAX events.- Specified by:
writePayloadTo
in classAbstractMessageImpl
fragment
- if true, this method will fire SAX events without start/endDocument events, suitable for embedding this into a bigger SAX event sequence. if false, this method generaets a completely SAX event sequence on its own.- Throws:
SAXException
-
copy
public Message copy()
Description copied from class:Message
Creates a copy of aMessage
.This method creates a new
Message
whose header/payload/attachments/properties are identical to thisMessage
. Once created, the createdMessage
and the originalMessage
behaves independently --- adding header/ attachment to oneMessage
doesn't affect anotherMessage
at all.This method does NOT consume a message.
To enable efficient copy operations, there's a few restrictions on how copied message can be used.
- The original and the copy may not be
used concurrently by two threads (this allows two
Message
s to share some internal resources, such as JAXB marshallers.) Note that it's OK for the original and the copy to be processed by two threads, as long as they are not concurrent. - The copy has the same 'life scope'
as the original (this allows shallower copy, such as
JAXB beans wrapped in
JAXBMessage
.)
A 'life scope' of a message created during a message processing in a pipeline is until a pipeline processes the next message. A message cannot be kept beyond its life scope. (This experimental design is to allow message objects to be reused --- feedback appreciated.)
Design Rationale
Since a
Message
body is read-once, sometimes (such as when you do fail-over, or WS-RM) you need to create an idential copy of aMessage
.The actual copy operation depends on the layout of the data in memory, hence it's best to be done by the
Message
implementation itself.The restrictions placed on the use of copied
Message
can be relaxed if necessary, but it will make the copy method more expensive.IMPORTANT
WHEN YOU IMPLEMENT OR CHANGE A {@link .copy()} METHOD, YOU MUST USE THE
Message.copyFrom(com.sun.xml.ws.api.message.Message)
METHOD IN THE IMPLEMENTATION. - The original and the copy may not be
used concurrently by two threads (this allows two
-
readAsSOAPMessage
public jakarta.xml.soap.SOAPMessage readAsSOAPMessage() throws jakarta.xml.soap.SOAPException
Description copied from class:AbstractMessageImpl
Default implementation that usesAbstractMessageImpl.writeTo(ContentHandler, ErrorHandler)
- Overrides:
readAsSOAPMessage
in classAbstractMessageImpl
- Throws:
jakarta.xml.soap.SOAPException
- if there's any error while creating aSOAPMessage
.
-
writeTo
public void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler) throws SAXException
Description copied from class:AbstractMessageImpl
Writes the whole envelope as SAX events.- Overrides:
writeTo
in classAbstractMessageImpl
- Parameters:
contentHandler
- must not be nulll.errorHandler
- must not be null. any error encountered during the SAX event production must be first reported to this error handler. Fatal errors can be then thrown asSAXParseException
.SAXException
s thrown fromErrorHandler
should propagate directly through this method.- Throws:
SAXException
-
-