org.mule.providers.tcp.protocols
Class LengthProtocol
java.lang.Object
org.mule.providers.tcp.protocols.ByteProtocol
org.mule.providers.tcp.protocols.DefaultProtocol
org.mule.providers.tcp.protocols.LengthProtocol
- All Implemented Interfaces:
- TcpProtocol
- Direct Known Subclasses:
- MuleMessageLengthProtocol
public class LengthProtocol
- extends DefaultProtocol
The LengthProtocol is an application level tcp protocol that can be used to
transfer large amounts of data without risking some data to be loss. The protocol
is defined by sending / reading an integer (the packet length) and then the data
to be transferred.
Note that use of this protocol must be symmetric - both the sending and receiving
connectors must use the same protocol.
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LengthProtocol
public LengthProtocol()
read
public Object read(InputStream is)
throws IOException
- Description copied from interface:
TcpProtocol
- Reads the input stream and returns a whole message.
- Specified by:
read
in interface TcpProtocol
- Overrides:
read
in class DefaultProtocol
- Parameters:
is
- the input stream
- Returns:
- an array of byte containing a full message
- Throws:
IOException
- if an exception occurs
writeByteArray
protected void writeByteArray(OutputStream os,
byte[] data)
throws IOException
- Overrides:
writeByteArray
in class ByteProtocol
- Throws:
IOException
isRepeat
protected boolean isRepeat(int len,
int available)
- Read all four bytes for initial integer (limit is set in read)
- Overrides:
isRepeat
in class DefaultProtocol
- Parameters:
len
- Amount transferred last call (-1 on EOF or socket error)available
- Amount available
- Returns:
- true if the transfer should continue
Copyright © 2003-2008 MuleSource, Inc.. All Rights Reserved.