You should use the HttpSessionBindingListener for closing your
hibernate session when the user session expires.  You can use the
HttpSessionListener if you want, but when sessionDestroyed() gets
called the session is already gone.  So it doesnt help much.

Use HttpSessionBindingListener.valueUnbound().  This will get called
just before the session is destroyed so you can read your session. 
I'm doing something similar with hibernate and this seems to work
well.  In flowscript Im doing:
cocoon.session.setAttribute("listener", new
com.li.wedge.client.WedgeSessionListener());

The session listener has to be part of the session itself to get called.

Hope this helps,

- Brent

On Tue, 03 Aug 2004 19:34:08 -0700, Joel McConaughy
<[EMAIL PROTECTED]> wrote:
> Good to hear from you, Mark.  Actually, what I'd like to do is keep the
> session factory open during the course of either the session or
> application context.  Then I can just open and close sessions as needed
> -- hopefully providing a performance improvement.  If there really isn't
> any way to get notified when the session or application context get
> invalidated so I can close the factory, then they are pretty useless IMO.
> 
> As an alternative, I could write an HttpSessionListener implementation
> however since this is called by the container (configured in the web.xml
> file), I don't know how to access it from Flow.
> 
> This is one of those things that seems like it should be simple.  Any
> ideas?  Thanks in advance.
> 
> 
> 
> 
> Mark Lundquist wrote:
> 
> >
> > On Aug 3, 2004, at 6:20 PM, Joel McConaughy wrote:
> >
> >> I would like to open one hibernate session for each user session and
> >> close it when the session is invalidated or times out.  I can see how
> >> save the hibernate session in Flow using
> >> cocoon.session.setAttribute() and cocoon.session.getAttribute()
> >> however there doesn't seem to be a way to get notified when the
> >> session gets invalidated so I can close the hibernate session.   Is
> >> there a way to do this?
> >
> >
> > Hi Joel,
> >
> > Just curious, why do you want the Hibernate session to have the same
> > lifetime as the user session?  Typically, in a web application context
> > a Hibernate session should be thought of as corresponding to a single
> > HTTP request/reply.
> >
> > See also this article:
> > http://cocoon.apache.org/2.1/userdocs/forms/index.html
> >
> > Actually, they make mention of the "session-per-user-session
> > anti-pattern" at the end of that article...
> >
> > Cheers,
> > ~ml
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
>

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

Reply via email to