public abstract class AbstractSynchronousByteArrayCommandTransport extends SynchronousCommandTransport
SynchronousCommandTransport that works with byte[] instead of command object.
This base class hides away some of the Command serialization details. One less thing
for transport implementers to worry about.CommandTransport.CommandReceiverchannel| Constructor and Description |
|---|
AbstractSynchronousByteArrayCommandTransport() |
| Modifier and Type | Method and Description |
|---|---|
Command |
read()
Called by
Channel to read the next command to arrive from the stream. |
abstract byte[] |
readBlock(Channel channel)
Read a byte[] from the underlying transport for the given channel.
|
void |
write(Command cmd,
boolean last)
Called by
Channel to send one command to the other side. |
abstract void |
writeBlock(Channel channel,
byte[] payload)
Writes a byte[] to the transport.
|
setupcloseRead, closeWrite, getRemoteCapabilitypublic AbstractSynchronousByteArrayCommandTransport()
public abstract byte[] readBlock(Channel channel) throws IOException, ClassNotFoundException
IOExceptionClassNotFoundExceptionpublic abstract void writeBlock(Channel channel, byte[] payload) throws IOException
readBlock(Channel) (unlike TCP, where a single write can
be split into multiple read()s on the other side.)IOExceptionpublic Command read() throws IOException, ClassNotFoundException
SynchronousCommandTransportChannel to read the next command to arrive from the stream.read in class SynchronousCommandTransportIOExceptionClassNotFoundExceptionpublic void write(Command cmd, boolean last) throws IOException
CommandTransportChannel to send one command to the other side.
Channel serializes the invocation of this method for ordering. That is,
at any given point in time only one thread executes this method.
Asynchronous transport must serialize the given command object before returning from this method, as its content can be modified by the calling thread as soon as this method returns. Also, if an asynchronous transport chooses to return from this method without committing data to the network, then it is also responsible for a flow control (by blocking this method if too many commands are queueing up waiting for the network to unclog.)
write in class CommandTransportcmd - The command object that needs to be sent. Never null. This must be
serialized via Command.writeTo(Channel, ObjectOutputStream)last - Informational flag that indicates that this is the last
call of the CommandTransport.write(Command, boolean).IOExceptionCopyright © 2004–2020. All rights reserved.