cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sylvain Wallez <sylv...@apache.org>
Subject Re: Session Timeout listener (was: RE: [RT] The API for the request object)
Date Tue, 06 Jul 2004 19:58:15 GMT
Hunsberger, Peter wrote:

>Colin Paul Adams <colin@colina.demon.co.uk> writes:
>
><snip>flow listener discussion,/snip>
>  
>
>>I've just read this thread, because I have been trying to 
>>work out how to implement pessimistic locking within cocoon. 
>>A problem is how to close a database transaction if the user 
>>simply walks away from the computer for a few hours, in the 
>>middle of a transaction. Session timeout will close the 
>>session, but a session listener is needed to then go and 
>>rollback the database transaction (or any other such resources held).
>>    
>>
>
>Maybe I'm missing something, but why aren't you setting your database
>transaction timeout limit to something just a bit larger than the
>session timeout?  Or, alternatively, if you're using EJB's, set your
>container TX timeout?  In either case the appropriate catch clause in
>your code can then do resource clean up as needed...
>  
>

Or you can also add store in a session attribute an object implementing 
javax.servlet.http.HttpSessionBindingListener that will be called 
whenever the session expires. This allows to perform any cleanup that 
you need.

Remember however, that holding costly resources like DB connections 
between request is generally considered bad practice in webapps, because 
of this very problem of detecting that a user has left.

Sylvain

-- 
Sylvain Wallez                                  Anyware Technologies
http://www.apache.org/~sylvain           http://www.anyware-tech.com
{ XML, Java, Cocoon, OpenSource }*{ Training, Consulting, Projects }


Mime
View raw message