Class TransportDispatcher

java.lang.Object
org.simpleframework.transport.TransportDispatcher
All Implemented Interfaces:
Runnable, Operation

class TransportDispatcher extends Object implements Operation
The TransportDispatcher operation is used transfer a transport to the processor so it can be processed. This is used so that when a transport is given to the processor it can be dispatched in another thread to the processor. This is needed so that the connection thread is occupied only briefly.
  • Field Details

    • processor

      private final TransportProcessor processor
      This is the processor used to transfer the transport to.
    • transport

      private final Transport transport
      This is the transport to be passed to the processor.
  • Constructor Details

    • TransportDispatcher

      public TransportDispatcher(TransportProcessor processor, Transport transport)
      Constructor for the TransportDispatcher object. This is used to transfer a transport to a processor. Transferring the transport using an operation ensures that the thread that is used to process the transport is not occupied for long.
      Parameters:
      processor - this is the negotiation to dispatch to
      transport - this is the transport this exchange uses
  • Method Details

    • getChannel

      public SocketChannel getChannel()
      This is the SelectableChannel which is used to determine if the operation should be executed. If the channel is ready for a given I/O event it can be run. For instance if the operation is used to perform some form of read operation it can be executed when ready to read data from the channel.
      Specified by:
      getChannel in interface Operation
      Returns:
      this returns the channel used to govern execution
    • getTrace

      public Trace getTrace()
      This is used to acquire the trace object that is associated with the operation. A trace object is used to collection details on what operations are being performed. For instance it may contain information relating to I/O events or errors.
      Specified by:
      getTrace in interface Operation
      Returns:
      this returns the trace associated with this operation
    • run

      public void run()
      This is used to transfer the transport to the processor. This will typically be executed asynchronously so that it does not delay the thread that passes the Transport to the transport processor, ensuring quicker processing.
      Specified by:
      run in interface Runnable
    • cancel

      public void cancel()
      This is used to cancel the operation if it has timed out. This is typically invoked when it has been waiting in a selector for an extended duration of time without any active operations on it. In such a case the reactor must purge the operation to free the memory and open channels associated with the operation.
      Specified by:
      cancel in interface Operation