com.sun.xml.ws.message
Class AbstractMessageImpl

java.lang.Object
  extended by com.sun.xml.ws.api.message.Message
      extended by com.sun.xml.ws.message.AbstractMessageImpl
Direct Known Subclasses:
DOMMessage, EmptyMessageImpl, JAXBMessage, PayloadStreamReaderMessage, StreamMessage, XMLMessage.UnknownContent, XMLMessage.XMLMultiPart

public abstract class AbstractMessageImpl
extends Message

Partial Message implementation.

This class implements some of the Message methods. The idea is that those implementations may be non-optimal but it may save effort in implementing Message and reduce the code size.

Message classes that are used more commonly should examine carefully which method can be implemented faster, and override them accordingly.


Field Summary
protected static AttributesImpl EMPTY_ATTS
           
protected static LocatorImpl NULL_LOCATOR
           
protected  SOAPVersion soapVersion
          SOAP version of this message.
 
Fields inherited from class com.sun.xml.ws.api.message.Message
attachmentSet
 
Constructor Summary
protected AbstractMessageImpl(AbstractMessageImpl that)
          Copy constructor.
protected AbstractMessageImpl(SOAPVersion soapVersion)
           
 
Method Summary
 javax.xml.soap.SOAPMessage readAsSOAPMessage()
          Default implementation that uses writeTo(ContentHandler, ErrorHandler)
 javax.xml.soap.SOAPMessage readAsSOAPMessage(Packet packet, boolean inbound)
          Creates the equivalent SOAPMessage from this message.
 Source readEnvelopeAsSource()
          Consumes this message including the envelope.
<T> T
readPayloadAsJAXB(Bridge<T> bridge)
          Reads the payload as a JAXB object according to the given Bridge.
<T> T
readPayloadAsJAXB(Unmarshaller unmarshaller)
          Reads the payload as a JAXB object by using the given unmarshaller.
protected abstract  void writePayloadTo(ContentHandler contentHandler, ErrorHandler errorHandler, boolean fragment)
          Writes the payload to SAX events.
 void writeTo(ContentHandler contentHandler, ErrorHandler errorHandler)
          Writes the whole envelope as SAX events.
 void writeTo(javax.xml.stream.XMLStreamWriter w)
          Default implementation that relies on Message.writePayloadTo(XMLStreamWriter)
 
Methods inherited from class com.sun.xml.ws.api.message.Message
assertOneWay, consume, copy, getAttachments, getHeaders, getID, getID, getMethod, getOperation, getOperation, getPayloadLocalPart, getPayloadNamespaceURI, hasAttachments, hasHeaders, hasPayload, isFault, isOneWay, readPayload, readPayloadAsSource, writePayloadTo
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

soapVersion

protected final SOAPVersion soapVersion
SOAP version of this message. Used to implement some of the methods, but nothing more than that.

So if you aren't using those methods that use this field, this can be null.


EMPTY_ATTS

protected static final AttributesImpl EMPTY_ATTS

NULL_LOCATOR

protected static final LocatorImpl NULL_LOCATOR
Constructor Detail

AbstractMessageImpl

protected AbstractMessageImpl(SOAPVersion soapVersion)

AbstractMessageImpl

protected AbstractMessageImpl(AbstractMessageImpl that)
Copy constructor.

Method Detail

readEnvelopeAsSource

public Source readEnvelopeAsSource()
Description copied from class: Message
Consumes this message including the envelope. returns it as a Source object.

Specified by:
readEnvelopeAsSource in class Message

readPayloadAsJAXB

public <T> T readPayloadAsJAXB(Unmarshaller unmarshaller)
                    throws JAXBException
Description copied from class: Message
Reads the payload as a JAXB object by using the given unmarshaller. This consumes the message.

Specified by:
readPayloadAsJAXB in class Message
Throws:
JAXBException - If JAXB reports an error during the processing.

readPayloadAsJAXB

public <T> T readPayloadAsJAXB(Bridge<T> bridge)
                    throws JAXBException
Description copied from class: Message
Reads the payload as a JAXB object according to the given Bridge. This consumes the message.

Specified by:
readPayloadAsJAXB in class Message
Returns:
null if there's no payload.
Throws:
JAXBException - If JAXB reports an error during the processing.

writeTo

public void writeTo(javax.xml.stream.XMLStreamWriter w)
             throws javax.xml.stream.XMLStreamException
Default implementation that relies on Message.writePayloadTo(XMLStreamWriter)

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

writeTo

public void writeTo(ContentHandler contentHandler,
                    ErrorHandler errorHandler)
             throws SAXException
Writes the whole envelope as SAX events.

Specified by:
writeTo in class Message
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 as SAXParseException. SAXExceptions thrown from ErrorHandler should propagate directly through this method.
Throws:
SAXException

writePayloadTo

protected abstract void writePayloadTo(ContentHandler contentHandler,
                                       ErrorHandler errorHandler,
                                       boolean fragment)
                                throws SAXException
Writes the payload to SAX events.

Parameters:
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

readAsSOAPMessage

public javax.xml.soap.SOAPMessage readAsSOAPMessage()
                                             throws javax.xml.soap.SOAPException
Default implementation that uses writeTo(ContentHandler, ErrorHandler)

Specified by:
readAsSOAPMessage in class Message
Throws:
javax.xml.soap.SOAPException - if there's any error while creating a SOAPMessage.

readAsSOAPMessage

public javax.xml.soap.SOAPMessage readAsSOAPMessage(Packet packet,
                                                    boolean inbound)
                                             throws javax.xml.soap.SOAPException
Description copied from class: Message
Creates the equivalent SOAPMessage from this message. It also uses transport specific headers from Packet during the SOAPMessage construction so that SOAPMessage.getMimeHeaders() gives meaningful transport headers. This consumes the message.

Overrides:
readAsSOAPMessage in class Message
Throws:
javax.xml.soap.SOAPException - if there's any error while creating a SOAPMessage.