com.sun.xml.ws.encoding.xml
Class XMLMessage.UnknownContent

java.lang.Object
  extended by com.sun.xml.ws.api.message.Message
      extended by com.sun.xml.ws.message.AbstractMessageImpl
          extended by com.sun.xml.ws.encoding.xml.XMLMessage.UnknownContent
All Implemented Interfaces:
XMLMessage.MessageDataSource
Enclosing class:
XMLMessage

public static class XMLMessage.UnknownContent
extends AbstractMessageImpl
implements XMLMessage.MessageDataSource

Don't know about this content. It's conent-type is NOT the XML types we recognize(text/xml, application/xml, multipart/related;text/xml etc). This could be used to represent image/jpeg etc


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
XMLMessage.UnknownContent(javax.activation.DataSource ds)
           
XMLMessage.UnknownContent(String ct, InputStream in)
           
 
Method Summary
 Message copy()
          Creates a copy of a Message.
 javax.activation.DataSource getDataSource()
          Get the data source.
 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 a Message has a payload.
 boolean hasUnconsumedDataSource()
          Check if the data source has been consumed.
 boolean isFault()
          Returns true if this message is a fault.
 javax.xml.stream.XMLStreamReader readPayload()
          Reads the payload as a XMLStreamReader This consumes the message.
 Source readPayloadAsSource()
          Returns the payload as a Source object.
protected  void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment)
          Writes the payload to SAX events.
 void writePayloadTo(javax.xml.stream.XMLStreamWriter sw)
          Writes the payload to StAX.
 
Methods inherited from class com.sun.xml.ws.message.AbstractMessageImpl
readAsSOAPMessage, readAsSOAPMessage, readEnvelopeAsSource, readPayloadAsJAXB, readPayloadAsJAXB, writeTo, writeTo
 
Methods inherited from class com.sun.xml.ws.api.message.Message
assertOneWay, consume, getAttachments, getID, getID, getMethod, getOperation, getOperation, hasAttachments, isOneWay
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XMLMessage.UnknownContent

public XMLMessage.UnknownContent(String ct,
                                 InputStream in)

XMLMessage.UnknownContent

public XMLMessage.UnknownContent(javax.activation.DataSource ds)
Method Detail

hasUnconsumedDataSource

public boolean hasUnconsumedDataSource()
Description copied from interface: XMLMessage.MessageDataSource
Check if the data source has been consumed.

Specified by:
hasUnconsumedDataSource in interface XMLMessage.MessageDataSource
Returns:
true of the data source has been consumed, otherwise false.

getDataSource

public javax.activation.DataSource getDataSource()
Description copied from interface: XMLMessage.MessageDataSource
Get the data source.

Specified by:
getDataSource in interface XMLMessage.MessageDataSource
Returns:
the data source.

writePayloadTo

protected 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 class AbstractMessageImpl
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

hasHeaders

public boolean hasHeaders()
Description copied from class: Message
Returns true if headers are present in the message.

Specified by:
hasHeaders in class Message
Returns:
true if headers are present.

isFault

public boolean isFault()
Description copied from class: Message
Returns true if this message is a fault.

Just a convenience method built on Message.getPayloadNamespaceURI() and Message.getPayloadLocalPart().

Overrides:
isFault in class Message

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 of HeaderList object. So if you only want to check for the existence of any header element, use Message.hasHeaders().

Specified by:
getHeaders in class Message
Returns:
always return the same non-null object.

getPayloadLocalPart

public String getPayloadLocalPart()
Description copied from class: Message
Gets the local name of the payload element.

Specified by:
getPayloadLocalPart in class Message
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 class Message
Returns:
null if a Message doesn't have any payload.

hasPayload

public boolean hasPayload()
Description copied from class: Message
Returns true if a Message 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 class Message

readPayloadAsSource

public Source readPayloadAsSource()
Description copied from class: Message
Returns the payload as a Source object. This consumes the message.

Specified by:
readPayloadAsSource in class Message
Returns:
if there's no payload, this method returns null.

readPayload

public javax.xml.stream.XMLStreamReader readPayload()
                                             throws javax.xml.stream.XMLStreamException
Description copied from class: Message
Reads the payload as a XMLStreamReader This consumes the message. The caller is encouraged to call XMLStreamReaderFactory.recycle(XMLStreamReader) when finished using the instance.

Specified by:
readPayload in class Message
Returns:
If there's no payload, this method returns null. Otherwise always non-null valid XMLStreamReader that points to the payload tag name.
Throws:
javax.xml.stream.XMLStreamException

writePayloadTo

public void writePayloadTo(javax.xml.stream.XMLStreamWriter sw)
                    throws javax.xml.stream.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 write XMLStreamWriter.writeStartDocument() nor XMLStreamWriter.writeEndDocument()

If there's no payload, this method is no-op.

Specified by:
writePayloadTo in class Message
Throws:
javax.xml.stream.XMLStreamException - If the XMLStreamWriter reports an error, or some other errors happen during the processing.

copy

public Message copy()
Description copied from class: Message
Creates a copy of a Message.

This method creates a new Message whose header/payload/attachments/properties are identical to this Message. Once created, the created Message and the original Message behaves independently --- adding header/ attachment to one Message doesn't affect another Message 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.

  1. The original and the copy may not be used concurrently by two threads (this allows two Messages 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.
  2. 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 a Message.

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.

Specified by:
copy in class Message