org.mule.providers.tcp.protocols
Class DefaultProtocol

java.lang.Object
  extended byorg.mule.providers.tcp.protocols.ByteProtocol
      extended byorg.mule.providers.tcp.protocols.DefaultProtocol
All Implemented Interfaces:
TcpProtocol
Direct Known Subclasses:
EOFProtocol, LengthProtocol, MuleMessageProtocol

public class DefaultProtocol
extends ByteProtocol

The DefaultProtocol class is an application level tcp protocol that does nothing. The socket is read until no more bytes are (momentariy) available (previously the transfer buffer also had to be full on the previous read, which made stronger requirements on the underlying network). On slow networks EOFProtocol and LengthProtocol may be more reliable.

Writing simply writes the data to the socket.


Field Summary
 
Fields inherited from class org.mule.providers.tcp.protocols.ByteProtocol
EOF, NO_STREAM, STREAM_OK
 
Constructor Summary
DefaultProtocol()
           
DefaultProtocol(boolean streamOk, int bufferSize)
           
 
Method Summary
protected  boolean isRepeat(int len, int available)
          Decide whether to repeat transfer.
 Object read(InputStream is)
          Reads the input stream and returns a whole message.
 Object read(InputStream is, int limit)
           
 
Methods inherited from class org.mule.providers.tcp.protocols.ByteProtocol
copy, copy, 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

DefaultProtocol

public DefaultProtocol()

DefaultProtocol

public DefaultProtocol(boolean streamOk,
                       int bufferSize)
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

read

public Object read(InputStream is,
                   int limit)
            throws IOException
Throws:
IOException

isRepeat

protected boolean isRepeat(int len,
                           int available)
Decide whether to repeat transfer. This implementation does so if more data are available. Note that previously, while documented as such, there was also the additional requirement that the previous transfer completely used the transfer buffer.

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.