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.
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 java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
XmlMessageProtocol
public XmlMessageProtocol()
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
Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.