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 LengthProtocol

    java.lang.Object
      org.mule.transport.tcp.protocols.AbstractByteProtocol
          org.mule.transport.tcp.protocols.DirectProtocol
              org.mule.transport.tcp.protocols.LengthProtocol

All Implemented Interfaces:
  TcpProtocol

Direct Known Subclasses:
  CustomClassLoadingLengthProtocol, MuleMessageLengthProtocol

    public class LengthProtocol

extends DirectProtocol

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.

Field Summary
`static int` | `NO_MAX_LENGTH`

Fields inherited from class org.mule.transport.tcp.protocols.DirectProtocol
`bufferSize, UNLIMITED`

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

Constructor Summary
`LengthProtocol()`
`LengthProtocol(int maxMessageLength)`

Method Summary
`int` | `getMaxMessageLength()`
`protected boolean` | `isRepeat(int len, int available)` Read all four bytes for initial integer (limit is set in read)
`Object` | `read(InputStream is)` Reads the input stream and returns a whole message.
`void` | `setMaxMessageLength(int maxMessageLength)`
`protected void` | `writeByteArray(OutputStream os, byte[] data)`

Methods inherited from class org.mule.transport.tcp.protocols.DirectProtocol
`read, remaining`

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

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

Field Detail

### NO_MAX_LENGTH

    public static final int NO_MAX_LENGTH

See Also:
  Constant Field Values

Constructor Detail

### LengthProtocol

    public LengthProtocol()

### LengthProtocol

    public LengthProtocol(int maxMessageLength)

Method Detail

### 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 `DirectProtocol`
  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 `AbstractByteProtocol`
  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 `DirectProtocol`
  Parameters:
    `len` - Amount transferred last call (-1 on EOF or socket error)
    `available` - Amount available
  Returns:
    true if the transfer should continue

### getMaxMessageLength

    public int getMaxMessageLength()

### setMaxMessageLength

    public void setMaxMessageLength(int maxMessageLength)

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-2010 MuleSoft, Inc.. All Rights Reserved.