sessionClosing event???

2002-01-21 Thread Matt Veitas

I was looking through the code in StandardSession regarding removing an
attribute from the session. I was puzzled that the attributes were removed
and the event fired off...is there a reason for this?

What I am trying to do is to do some cleanup work on the object that was
bound to the session (doing some database stuff). Since the attributes in
the session are removed before the valueUnbound or sessionDestroyed events
are called, I can't do my clean up. Is there any way around this without
going in and changing the code?

I would like to propose additional an additional method such as a
sessionClosing() method so you can do some cleanup before it actually is
invalidated. What do people this about this?


_
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


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




Re: sessionClosing event???

2002-01-21 Thread Craig R. McClanahan



On Sun, 20 Jan 2002, Matt Veitas wrote:

 Date: Sun, 20 Jan 2002 18:39:37 -0500
 From: Matt Veitas [EMAIL PROTECTED]
 Reply-To: Tomcat Developers List [EMAIL PROTECTED],
  [EMAIL PROTECTED]
 To: [EMAIL PROTECTED]
 Subject: sessionClosing event???

 I was looking through the code in StandardSession regarding removing an
 attribute from the session. I was puzzled that the attributes were removed
 and the event fired off...is there a reason for this?


Servlet Specification, version 2.3, section 7.4:

The valueUnbound method must be called after the object
is no longer available via the getAttribute method of the
HttpSession interface

In essence, this guarantees that no other simultaneous threads accessing
this session will be able to grab your object while you are doing your
cleanup processing.

 What I am trying to do is to do some cleanup work on the object that was
 bound to the session (doing some database stuff). Since the attributes in
 the session are removed before the valueUnbound or sessionDestroyed events
 are called, I can't do my clean up. Is there any way around this without
 going in and changing the code?


Why can't you do your cleanup in the valueUnbound method?  It's been in
the servlet API for exactly this reason since at least 2.0 days.  And, the
HttpSessionBindingEvent you receive has a reference to the session itself,
and the attribute name you were formerly bound under, so you can go clean
up related things as well.

 I would like to propose additional an additional method such as a
 sessionClosing() method so you can do some cleanup before it actually is
 invalidated. What do people this about this?


This would need to be added to the servlet spec to be generally useful --
the appropriate place to recommend it would be the spec feedback address:
[EMAIL PROTECTED].

Craig


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