Pages

Thursday 27 June 2013

What is the flow of http request in Liferay

Flow of Request in Liferay:-


Browser » App Server (eg Tomcat) » Liferay(Main Servlet) » layout (Database Table of Liferay) 

>>Creates and construsts Theme display object » Page Layout » Portlets » portlet.vm » portal_normal.vm » HTML


1).When a url is request by browser, the application server (Tomcat or any other server running Liferay) handles the request and forwards it to Liferay(MainServlet in portal.jar). and then creates and construts themedisplay object which contain all the various configuration parameters and values
2). From the request URL Liferay get the ‘page’ that is requested. This page is searched for the corresponding record in table ‘layout’ to check the page layout.
3). From page layout the portlets on pages is retrieved. The portlets are processed and out is placed in ‘portlet.vm’. This velocity file with parsed data is set in page layout to construct the whole page and output is then set to ‘portal_normal.vm’. 
4).Finally ‘portal_normal.vm’ is converted to HTML that is presented to the user.

For Breif Discussion in depth.

Many time we think like when we hit a url in browser what is the intermediate class by which request comes to our class. Below steps describes the flow of a browser request thru the Liferay code from request of the page, all the way down to rendering an individual portlet: 
  1. The initial request comes into the portal server from the browser, and hits the service() method of the class com.liferay.portal.servlet.MainServlet. Here, a variety of objects are created and added to the request for use by code downstream (such as company Id, user objects, etc.)
  2. Code passes through the servicePre() method of the class com.liferay.portal.events.ServicePreAction. Here is where the ThemeDisplay object is created and populated for downstream code use.
  3. The theme infrastucture code will call into the class com.liferay.taglib.util.ThemeUtil to render the content of a theme. It will call either the mehod includeJSP() to include JSP rendered content, or includeVM() to include Velocity rendered content.
  4. When using a Velocity based theme, the request will flow thru the class com.liferay.portal.velocity.VelocityVariables and the method insertVariables(). That method is where various Velocity variables for use by the theme system is added to the Velocity context.
  5. For each column in the page's layout, the PortletColumnLogic class processes each portlet using the processContent() method. In this method, the HTML that surrounds every portlet is generated. Further processing is then delegated to the RuntimePortletUtil via the processPortlet() method. Then on to the actual rendering...
  6. An individual portlet is rendered by the render_portlet.jsp code located (in Tomcat) in the webapps/ROOT/html/portal directory. This JSP is called to render each portlet on the page. Debug code can be added to this file to see exactly what is going on just before and just after the code in your custom portlet is executed.
  7. As will be found by looking through the JSP code, render_portlet.jsp uses InvokerPortletImpl's render() method to render portlets. The primary function of this method is to check if a portlet's expiration-cache has been set or has expired. If the expiration-cache has been set, InvokerPortletImpl then checks whether the portlet's most recently cached content is fresh enough to use.


Reference Link - See more at: http://www.opensourceforlife.com/2011/11/browser-request-thru-liferay-code.html#sthash.SJfqpfkZ.dpuf

1 comment:

  1. brillant piece of information, I had come to know about your web-page from my friend hardkik, chennai,i have read atleast 9 posts of yours by now, and let me tell you, your webpage gives the best and the most interesting information. This is just the kind of information that i had been looking for, i'm already your rss reader now and i would regularly watch out for the new posts, once again hats off to you! Thanx a million once again, Regards, liferay training in hyderabad

    ReplyDelete