public abstract class SynchronousCommandTransport extends CommandTransport
CommandTransportthat implements the read operation in a synchronous fashion.
This class uses a thread to pump commands and pass them to
|Constructor and Description|
|Modifier and Type||Method and Description|
Starts the transport.
closeRead, closeWrite, getRemoteCapability, write
protected Channel channel
public abstract Command read() throws IOException, ClassNotFoundException, InterruptedException
Channelto read the next command to arrive from the stream.
public void setup(Channel channel, CommandTransport.CommandReceiver receiver)
Channel, after the
CommandTransport.getRemoteCapability()is invoked. The first purpose of this method is to provide a reference back to
Channel, and the second purpose of this method is to allow
CommandTransportto message pumping, where it starts receiving commands from the other side and pass them onto
CommandTransport.CommandReceiver. This abstraction enables asynchronous processing — for example you can have a single thread serving a large number of
Channels via NIO. For subtypes that prefer synchronous operation, extend from
Channel.CloseCommand its own "end of command stream" marker, and
therefore under the orderly shutdown scenario, it doesn't rely on the transport to provide EOF-like
Channel will call your
CommandTransport.closeRead() (from the same thread
CommandTransport.CommandReceiver.handle(Command)) to indicate that it is done with the reading.
If the transport encounters any error from the lower layer (say, the underlying TCP/IP socket
encountered a REST), then call
CommandTransport.CommandReceiver.terminate(IOException) to initiate the abnormal
channel termination. This in turn calls
CommandTransport.closeRead() to shutdown the reader side.
Copyright © 2004–2021. All rights reserved.