portlet lifecycle

Hi,

I have developed some liferay portlets with Vaadin. My Application class implements PortletRequestListener, thus having onRequestStart(PortletRequest request, PortletResponse response) and onRequestEnd(PortletRequest request, PortletResponse response) methods. I have some general questions on the lifecycle of a portlet.

  1. I’m missing a “destroy” method as a counterpart to “init”. Where is the best place to do some clean up when the session has ended i.e. the user has logged out etc.
  2. By now, I fetch user information with the PortletRequest object. I have recognized that ‘onRequestStart()’ gets called before the application’s ‘init()’ method. Actually this is what I want, but shouldn’t it be the opposite way? ‘init()’ first, then ‘onRequestStart()’?

I hope someone can help me.
Andi

For non portlet application, you can do your cleanup in the close() of Application.
I am not sure in the event of portlet but it can be worth a try.

Thanks for your answer, but isn’t the close() method just for shutting down the application manually? I don’t think it is called when the application stops.

I’m searching for a kind of listener which gets called when the user session ends (timeout, logout from liferay, etc) to do some cleanup.

Close is for both, see it as some equivalent to a destructor from C.
You can put System.out.println(“in close”) and see if it appears in your terminal when the session is destroyed.

Ok, I’ve checked it and close() is called automatically :slight_smile: Thanks! But the JavaDoc is somehow misleading…