|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.mule.transport.tcp.protocols.AbstractByteProtocol
public abstract class AbstractByteProtocol
This Abstract class has been introduced so as to have the byte protocols (i.e. the protocols that had only a single write method taking just an array of bytes as a parameter) to inherit from since they will all behave the same, i.e. if the object is serializable, serialize it into an array of bytes and send it.
Note that the raw write method has changed name from write
to
writeByteArray
. This is to remove ambiguity from the code. In almost
all cases it is possible to call write(java.io.OutputStream, Object)
which
will, via write(java.io.OutputStream, Object)
, dispatch to
writeByteArray(java.io.OutputStream, byte[])
.
Field Summary | |
---|---|
static int |
EOF
|
static boolean |
NO_STREAM
|
static boolean |
STREAM_OK
|
Constructor Summary | |
---|---|
AbstractByteProtocol(boolean streamOk)
|
Method Summary | |
---|---|
protected int |
copy(InputStream source,
byte[] buffer,
OutputStream dest)
Make a single transfer from source to dest via a byte array buffer |
protected int |
copy(InputStream source,
byte[] buffer,
OutputStream dest,
int size)
Make a single transfer from source to dest via a byte array buffer |
ResponseOutputStream |
createResponse(Socket socket)
This lets protocols encode a response stream. |
protected byte[] |
nullEmptyArray(byte[] data)
|
protected int |
safeRead(InputStream is,
byte[] buffer)
Manage non-blocking reads and handle errors |
protected int |
safeRead(InputStream is,
byte[] buffer,
int size)
Manage non-blocking reads and handle errors |
void |
write(OutputStream os,
Object data)
Write the specified message to the output stream. |
protected void |
writeByteArray(OutputStream os,
byte[] data)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface org.mule.transport.tcp.TcpProtocol |
---|
read |
Field Detail |
---|
public static final int EOF
public static final boolean STREAM_OK
public static final boolean NO_STREAM
Constructor Detail |
---|
public AbstractByteProtocol(boolean streamOk)
Method Detail |
---|
public void write(OutputStream os, Object data) throws IOException
TcpProtocol
write
in interface TcpProtocol
os
- the output stream to write todata
- the data to write
IOException
- if an exception occursprotected void writeByteArray(OutputStream os, byte[] data) throws IOException
IOException
protected int safeRead(InputStream is, byte[] buffer) throws IOException
is
- The input stream to read frombuffer
- The buffer to read into
IOException
- other than socket exceptionsprotected int safeRead(InputStream is, byte[] buffer, int size) throws IOException
is
- The input stream to read frombuffer
- The buffer to read intosize
- The amount of data (upper bound) to read
IOException
- other than socket exceptionsprotected int copy(InputStream source, byte[] buffer, OutputStream dest) throws IOException
source
- Source of databuffer
- Buffer array for transferdest
- Destination of data
IOException
- On non-socket errorprotected int copy(InputStream source, byte[] buffer, OutputStream dest, int size) throws IOException
source
- Source of databuffer
- Buffer array for transferdest
- Destination of datasize
- The amount of data (upper bound) to read
IOException
- On non-socket errorprotected byte[] nullEmptyArray(byte[] data)
public ResponseOutputStream createResponse(Socket socket) throws IOException
TcpProtocol
createResponse
in interface TcpProtocol
socket
- The destination to write to
IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |