XmlMessageProtocol (Mule ESB 2.2.1 API)
Keywords: org.mule.transport.tcp.protocols.XmlMessageProtocol class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.mule.transport.tcp.protocols
Class XmlMessageProtocol

    java.lang.Object
      org.mule.transport.tcp.protocols.AbstractByteProtocol
          org.mule.transport.tcp.protocols.XmlMessageProtocol

All Implemented Interfaces:
  TcpProtocol

Direct Known Subclasses:
  XmlMessageEOFProtocol

    public class XmlMessageProtocol

extends AbstractByteProtocol

The XmlMessageProtocol is an application level tcp protocol that can be used to read streaming xml documents. The only requirement is that each document include an xml declaration at the beginning of the document of the form "SHOULD begin with an XML declaration which specifies the version of XML being used" while the xml 1.1 standard contains "Definition: XML 1.1 documents MUST begin with an XML declaration which specifies the version of XML being used". The SHOULD indicates a recommendation that, if not followed, needs to be carefully checked for unintended consequences. MUST indicates a mandatory requirement for a well-formed document. Please make sure that the xml documents being streamed begin with an xml declaration when using this class.

Data are read until a new document is found or there are no more data (momentarily). For slower networks, `XmlMessageEOFProtocol` may be more reliable.

Also, the default character encoding for the platform is used to decode the message bytes when looking for the XML declaration. Some caution with message character encodings is warranted.

Finally, this class uses a PushbackInputStream to enable parsing of individual messages. The stream stores any pushed-back bytes into it's own internal buffer and not the original stream. Therefore, the read buffer size is intentionally limited to insure that unread characters remain on the stream so that all data may be read later.

Field Summary

Fields inherited from class org.mule.transport.tcp.protocols.AbstractByteProtocol
`EOF, NO_STREAM, STREAM_OK`

Constructor Summary
`XmlMessageProtocol()`

Method Summary
`protected boolean` | `isRepeat(int patternIndex, int len, int available)` Show we continue reading? This class, following previous implementations, only reads while input is saturated.
`Object` | `read(InputStream is)` Reads the input stream and returns a whole message.

Methods inherited from class org.mule.transport.tcp.protocols.AbstractByteProtocol
`copy, copy, createResponse, nullEmptyArray, safeRead, safeRead, write, writeByteArray`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### XmlMessageProtocol

    public XmlMessageProtocol()

Method Detail

### read

    public Object read(InputStream is)
                throws IOException

  Description copied from interface: `TcpProtocol`
  Reads the input stream and returns a whole message.

  Parameters:
    `is` - the input stream
  Returns:
    an array of byte containing a full message
  Throws:
    `IOException` - if an exception occurs

### isRepeat

    protected boolean isRepeat(int patternIndex,
                               int len,
                               int available)

  Show we continue reading? This class, following previous implementations, only reads while input is saturated.

  Parameters:
    `patternIndex` - The index of the xml tag (or -1 if the next message not found)
    `len` - The amount of data read this loop (or -1 if EOF)
    `available` - The amount of data available to read
  Returns:
    true if the read should continue
  See Also:
    `XmlMessageEOFProtocol`

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2009 MuleSource, Inc.. All Rights Reserved.