Class RequestDispatcher

  • All Implemented Interfaces:
    java.lang.Runnable

    class RequestDispatcher
    extends java.lang.Object
    implements java.lang.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:
    Container
    • Field Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void dispatch()
      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 Detail

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

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

      • 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 java.lang.Runnable
      • dispatch

        private void dispatch()
                       throws java.lang.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:
        java.lang.Exception