| Brian J. Sayatovic 2005-09-28, 6:04 pm |
| We're plaving some objects in the session that tie back to resources in our
backend that need to be cleaned up. My current approach is to use the
HttpSessionBindingListener on the PortletSession. When a special value is
unbound, it is interpreted as the session expiring, and the attached cleanup
logic is invoked.
One of the limitations of this is that other values in the session may have
already been unbound. order of unbinding is not guaranteed, so I have to
keep references to anythign I need to clean up within the one special
object.
I'm also not confident in how safe this is. I know when a session expihies
this will happen. Also, it will happen when a session is invalidated, which
we do on logout. what about when the server is gracefully shutting down?
In other words, I'm not sure I know how many ways the cleanup hook ight get
bypassed.
Someone recently suggested looking into the PortletSessionListener. This
appears to be a much more explicit event. However, some documentation I
found () says it doesn't handle server shutdown:
>logout()
When the user ends the session with the portal, the portal server calls the
logout() method to inform the portlet that the user's session instance is
terminating. The portlet should then clean up any resources for the portlet
user instance. This could include cleaning up, if necessary, the
authentication state of the user or cookies that might have been placed on
the browser by the portlet. At a minimum, any state on the backend
application should be cleaned up or marked as terminated to prevent any
remaining cookies on a subsequent request from being used.
Note: You cannot rely on the logout method being called when the portal is
shut down because the application server can destroy portlets and servlets
before the sessions are cleaned up. Therefore, the portlet is not available
at the time when the logout method should be called. If there are necessary
cleanup actions that a portlet must take when the portal server is shut
down, these must be done in the destroy method.
|