org.mule.transport.tcp.protocols
Class SafeProtocol

java.lang.Object
  extended by org.mule.transport.tcp.protocols.SafeProtocol
All Implemented Interfaces:
TcpProtocol
Direct Known Subclasses:
MuleMessageSafeProtocol

public class SafeProtocol
extends Object
implements TcpProtocol

This precedes every message with a cookie. It should probably not be used in production. We use ths protocol as the default because previously people tended to use DefaultProtocol without considering packet fragmentation etc. You should probably change to LengthProtocol. Remember - both sender and receiver must use the same protocol.


Field Summary
static String COOKIE
           
 
Constructor Summary
SafeProtocol()
           
 
Method Summary
 ResponseOutputStream createResponse(Socket socket)
          This lets protocols encode a response stream.
 Object read(InputStream is)
          Reads the input stream and returns a whole message.
 void setMaxMessageLength(int maxMessageLength)
           
 void write(OutputStream os, Object 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
 

Field Detail

COOKIE

public static final String COOKIE
See Also:
Constant Field Values
Constructor Detail

SafeProtocol

public SafeProtocol()
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
Parameters:
is - the input stream
Returns:
an array of byte containing a full message
Throws:
IOException - if an exception occurs

write

public void write(OutputStream os,
                  Object 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

createResponse

public ResponseOutputStream createResponse(Socket socket)
                                    throws IOException
Description copied from interface: TcpProtocol
This lets protocols encode a response stream. If the protocol does not support a response stream (ie does not support streaming) then the stream should thrown an exception when used.

Specified by:
createResponse in interface TcpProtocol
Parameters:
socket - The destination to write to
Returns:
A stream whose output will be encoded
Throws:
IOException

setMaxMessageLength

public void setMaxMessageLength(int maxMessageLength)


Copyright © 2003-2012 MuleSoft, Inc.. All Rights Reserved.