Saturday, 14 November 2015

Resting Groovy - Control Flow

In this post we will see how the GServConfig i.e. the config object gets constructed, followed by Control flow for Incoming Requests.



** GServInstance.start(<<PORT NUMBER>>). This method creates the HttpServer and registers the GServHandler (created in Step 3.1) with the context root "/". The GServHandler which extends HttpHandler acts like controller after it gets registered.

Along with this some init Filters also gets registered and stored in GServConfig, so that when the filters gets invoked from GServHandler.handle(HttpExchange) method, then these init filters also gets executed. Remember the context root being "/".

So for any incoming requests, the HttpHandler’s handle(HttpExchnage) gets invoked.

The HttpExchange class encapsulates a HTTP request received and a response to be generated in one exchange. It provides methods for examining the request from the client, and for building and sending the response.

So when the incoming request arrives the HttpExchange instance along with the GServConfig object (passed in Step 3) to create the GServ RequestContext, which is then passed along for invoking filters, plugins, Actions for a particular Request.



Please note, the depicted control is an overview of my understanding of gServ.

There can be Gap between my understanding and the actual flow. Please share your views and feedback.

If I am wrong or misunderstood some part of the gServ architecture and the control flow, I apologize for that and please correct me in that case.

I thought of sharing my idea about gServ because I thought that such effort may help us in knowing this awesome Groovy framework in a better way.

That’s it and until next time Keep Coding and Keep Contributing.

View Subhankar Paul's profile on LinkedIn

No comments:

Post a Comment