org.mule.providers.tcp.protocols
Class XmlMessageProtocol

java.lang.Object
  extended byorg.mule.providers.tcp.protocols.XmlMessageProtocol
All Implemented Interfaces:
TcpProtocol

public class XmlMessageProtocol
extends Object
implements TcpProtocol

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.

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.

Version:
$Revision: 3798 $
Author:
Rich Lucente

Constructor Summary
XmlMessageProtocol()
           
 
Method Summary
 byte[] read(InputStream is)
          Adapted from DefaultProtocol
 void write(OutputStream os, byte[] data)
          Write the specified message to the output stream.
 
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 byte[] read(InputStream is)
            throws IOException
Adapted from DefaultProtocol

Specified by:
read in interface TcpProtocol
Parameters:
is - the input stream
Returns:
an array of byte containing a full message
Throws:
IOException - if an exception occurs
See Also:
DefaultProtocol.read(java.io.InputStream)

write

public void write(OutputStream os,
                  byte[] data)
           throws IOException
Description copied from interface: TcpProtocol
Write the specified message to the output stream.

Specified by:
write in interface TcpProtocol
Parameters:
os - the output stream to write to
data - the data to write
Throws:
IOException - if an exception occurs


Copyright © 2003-2006 MuleSource Inc.. All Rights Reserved.