Class RequestReader

java.lang.Object
org.simpleframework.http.core.RequestReader
All Implemented Interfaces:
Runnable, Operation

class RequestReader extends Object implements Operation
The RequestReader object is used to read the bytes that form the request entity. In order to execute a read operation the socket must be read ready. This is determined using the socket object, which is registered with a controller. If at any point the reading results in an error the operation is cancelled and the collector is closed, which shuts down the connection.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Channel
    This is the channel object associated with the collector.
    private final Collector
    This is the collector used to consume the entity bytes.
    private final Controller
    This is the selector used to process the collection events.
    private final Trace
    This is used to collect any trace information.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RequestReader(Controller controller, Collector collector)
    Constructor for the RequestReader object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This is used to cancel the operation if it has timed out.
    This is the SocketChannel used to determine if the connection has some bytes that can be read.
    This is used to acquire the trace object that is associated with the operation.
    void
    run()
    This run method is used to collect the bytes from the connected channel.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • controller

      private final Controller controller
      This is the selector used to process the collection events.
    • collector

      private final Collector collector
      This is the collector used to consume the entity bytes.
    • channel

      private final Channel channel
      This is the channel object associated with the collector.
    • trace

      private final Trace trace
      This is used to collect any trace information.
  • Constructor Details

    • RequestReader

      public RequestReader(Controller controller, Collector collector)
      Constructor for the RequestReader object. This is used to collect the data required to compose a HTTP request. Once all the data has been read by this it is dispatched.
      Parameters:
      controller - the controller object used to process events
      collector - this is the task used to collect the entity
  • Method Details

    • 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
    • getChannel

      public SocketChannel getChannel()
      This is the SocketChannel used to determine if the connection has some bytes that can be read. If it contains any data then that data is read from and is used to compose the request entity, which consists of a HTTP header and body.
      Specified by:
      getChannel in interface Operation
      Returns:
      this returns the socket for the connected pipeline
    • run

      public void run()
      This run method is used to collect the bytes from the connected channel. If a sufficient amount of data is read from the socket to form a HTTP entity then the collector uses the Selector object to dispatch the request. This is sequence of events that occur for each transaction.
      Specified by:
      run in interface Runnable
    • cancel

      public void cancel()
      This is used to cancel the operation if it has timed out. If the retry is waiting too long to read content from the socket then the retry is cancelled and the underlying transport is closed. This helps to clean up occupied resources.
      Specified by:
      cancel in interface Operation