Showing posts with label life cycle. Show all posts
Showing posts with label life cycle. Show all posts

Tuesday, April 19, 2016

JSR 286 Lifecycle Explained

Though age old, thought of writing this post just to have a placeholder to detail the basic JSR 286 Portlet flow.

Following flow chart explains the basic flow of JSR 286 based portlet:


JSR 286 based portlet's flow

By overriding the major methods of GenericPortlet class and adding loggers on each method entry, we can easily view the flow of the portlets lifecycle.
  • After deploying the portlet, when it is being invoked for the first time (by visiting a page on which it is added) init method is called.
[2/18/16 17:10:55:925 IST] 000001c5 SystemOut     O JSR286LCCheck init method called
[2/18/16 17:10:55:926 IST] 000001c5 SystemOut     O JSR286LCCheck render method called, mode to be displayed is : view
[2/18/16 17:10:55:926 IST] 000001c5 SystemOut     O JSR286LCCheck doDispatch method called
[2/18/16 17:10:55:926 IST] 000001c5 SystemOut     O JSR286LCCheck doView method called

  • For all other subsequent calls, init is not invoked. On page refresh:
[2/18/16 17:13:23:309 IST] 00000145 SystemOut     O JSR286LCCheck render method called, mode to be displayed is : view
[2/18/16 17:13:23:310 IST] 00000145 SystemOut     O JSR286LCCheck doDispatch method called
[2/18/16 17:13:23:310 IST] 00000145 SystemOut     O JSR286LCCheck doView method called

  • On Form submit processAction is invoked and flowing is the flow: (Changed the portlet mode here to Edit mode). doDispatch redirects to the requested mode method:
[2/18/16 17:12:03:436 IST] 00000044 SystemOut     O JSR286LCCheck processAction method called
[2/18/16 17:12:03:741 IST] 00000044 SystemOut     O JSR286LCCheck render method called, mode to be displayed is : edit
[2/18/16 17:12:03:741 IST] 00000044 SystemOut     O JSR286LCCheck doDispatch method called
[2/18/16 17:12:03:741 IST] 00000044 SystemOut     O JSR286LCCheck doEdit method called


Once the mode is changed, it remains in the same mode till session is over or the mode is changed explicitly.
  • When serveResource is called, then only serveResource is called. It acts as an independent method.
[2/18/16 17:12:40:239 IST] 00000145 SystemOut     O JSR286LCCheck serveResource method
  • When the application is stopped, destroy method is called. Destroy will only be called if the portlet has been initialized / invoked. If the portlet has not been initialized, the destroy method will not be called.
[2/18/16 17:14:13:292 IST] 00000048 ApplicationMg A   WSVR0217I: Stopping application: PA_JSR286LCCheck
[2/18/16 17:14:13:301 IST] 00000048 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper doDestroy SRVE0253I: [PA_JSR286LCCheck] [/wps/PA_JSR286LCCheck] [/_JSR286LCCheck/jsp/html/JSR286LCCheckPortletView.jsp]: Destroy successful.
[2/18/16 17:14:13:302 IST] 00000048 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper doDestroy SRVE0253I: [PA_JSR286LCCheck] [/wps/PA_JSR286LCCheck] [/_JSR286LCCheck/jsp/html/JSR286LCCheckPortletEdit.jsp]: Destroy successful.
[2/18/16 17:14:13:302 IST] 00000048 SystemOut     O JSR286LCCheck destroy called
[2/18/16 17:14:13:302 IST] 00000048 ServletWrappe I com.ibm.ws.webcontainer.servlet.ServletWrapper doDestroy SRVE0253I: [PA_JSR286LCCheck] [/wps/PA_JSR286LCCheck] [JSR286LCCheck]: Destroy successful.
[2/18/16 17:14:13:584 IST] 00000048 ApplicationMg A   WSVR0220I: Application stopped: PA_JSR286LCCheck