Class RequestDispatcher

java.lang.Object
org.simpleframework.http.core.RequestDispatcher
All Implemented Interfaces:
Runnable

class RequestDispatcher extends Object implements Runnable
The RequestDispatcher object is used to dispatch a request and response to the container. This is the root task that executes all transactions. A transaction is dispatched to the container which can deal with it asynchronously, however as a safeguard the dispatcher will catch any exceptions thrown and close the connection if required. Closing the connection if an exception is thrown ensures that CLOSE_WAIT issues do not arise with open connections that can not be closed within the container.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Channel
    This is the channel associated with the request to dispatch.
    private final Container
    This is the container that is used to handle the transactions.
    private final ResponseObserver
    This is the observer object used to signal completion events.
    private final Request
    This is the request object which contains the request entity.
    private final Response
    This is the response object used to response to the request.
    private final Trace
    This is the trace that is used to track the request dispatch.
  • Constructor Summary

    Constructors
    Constructor
    Description
    RequestDispatcher(Container container, Controller controller, Entity entity)
    Constructor for the RequestDispatcher object.
  • Method Summary

    Modifier and Type
    Method
    Description
    private void
    This dispatch method will dispatch the request and response objects to the container.
    void
    run()
    This run method will dispatch the created request and response objects to the container.

    Methods inherited from class java.lang.Object

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

    • observer

      private final ResponseObserver observer
      This is the observer object used to signal completion events.
    • container

      private final Container container
      This is the container that is used to handle the transactions.
    • response

      private final Response response
      This is the response object used to response to the request.
    • request

      private final Request request
      This is the request object which contains the request entity.
    • channel

      private final Channel channel
      This is the channel associated with the request to dispatch.
    • trace

      private final Trace trace
      This is the trace that is used to track the request dispatch.
  • Constructor Details

    • RequestDispatcher

      public RequestDispatcher(Container container, Controller controller, Entity entity)
      Constructor for the RequestDispatcher object. This creates a request and response object using the provided entity, these can then be passed to the container to handle it.
      Parameters:
      container - this is the container to handle the request
      controller - the controller used to handle the next request
      entity - this contains the current request entity
  • Method Details

    • run

      public void run()
      This run method will dispatch the created request and response objects to the container. This will interpret the target and semantics from the request object and compose a response for the request which is sent to the connected client.
      Specified by:
      run in interface Runnable
    • dispatch

      private void dispatch() throws Exception
      This dispatch method will dispatch the request and response objects to the container. This will interpret the target and semantics from the request object and compose a response for the request which is sent to the connected client. If there is an exception this will close the socket channel.
      Throws:
      Exception