public abstract class AbstractByteProtocol extends Object implements TcpProtocol
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[])
.
Modifier and Type | Field and Description |
---|---|
static int |
EOF |
static boolean |
NO_STREAM |
static boolean |
STREAM_OK |
Constructor and Description |
---|
AbstractByteProtocol(boolean streamOk) |
Modifier and Type | Method and Description |
---|---|
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.
|
boolean |
isRethrowExceptionOnRead() |
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 |
setObjectSerializer(ObjectSerializer objectSerializer) |
void |
setRethrowExceptionOnRead(boolean rethrowExceptionOnRead) |
void |
write(OutputStream os,
Object data)
Write the specified message to the output stream.
|
protected void |
writeByteArray(OutputStream os,
byte[] data) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
read
public static final int EOF
public static final boolean STREAM_OK
public static final boolean NO_STREAM
public void write(OutputStream os, Object data) throws IOException
TcpProtocol
write
in interface TcpProtocol
os
- the output stream to write todata
- the data to writeIOException
- 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 intoIOException
- 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 readIOException
- other than socket exceptionsprotected int copy(InputStream source, byte[] buffer, OutputStream dest) throws IOException
source
- Source of databuffer
- Buffer array for transferdest
- Destination of dataIOException
- 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 readIOException
- 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 toIOException
public boolean isRethrowExceptionOnRead()
public void setRethrowExceptionOnRead(boolean rethrowExceptionOnRead)
@Inject public void setObjectSerializer(ObjectSerializer objectSerializer)
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.