After some discussion, and digging into the source code, looks like the Engine 
is what's stored in the HttpSession, and the Visit is stored in the Engine.

It would be nice if the Engine implemented the HttpSessionBindingListener 
interface and a new interface, DisposableVisit created so that when the session 
is unbound, the Engine can test if the Visit implements the DisposableVisit 
interface, and if so, calls a "dispose()" method on the Visit so developers can 
put their session specific cleanup in their Visit object.

I'm on a project now that uses a facade to talk to a hibernate session. After 
usage, the hibernate session needs to be released to the session pool. The key 
into the pool is a unique value assigned to the Visit object. I'd like to be 
able to keep a reference to that hibernate session for the duration of the 
user's HttpSession. This would solve that issue, with very minor coding.

Something as simple as this *should* work :

public interface DisposableVisit
{
  /**
   * Allow the user to clean up any session specific things.
   *
   */
  public void dispose();
}

And of course, in the Engine, implement the listener methods :
public void valueBound(HttpSessionBindingEvent event) 
{           
}

public void valueUnbound(HttpSessionBindingEvent event) 
{
        Object visit = getVisit();
        if (visit != null && visit instanceof DisposableVisit) 
        {
                visit.dispose();
        }
}

I guess this will all blow up if the valueUnbound() is called each time the 
object is put in the session ... ?

PS : Thx to Richard Hensley for the ideas about hooking this into the Engine.




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to