Mike Engelhart wrote:
> Hi all-
>
> I have a startup servlet which initializes a connection pool (THIS IS NOT A
> DATABASE CONNECTION POOL) to a legacy system that my webapp accesses. This
> servlet puts a singleton connection broker into the ServletContext and is
> shared among all my servlets. The destroy() method of this servlet then
> ensures that all connections in the broker object are closed. My problem
> is this:
> I have a class which is stored in the HttpSession of the user. This class
> implements HttpSessionBindingListener and then when the session is unbound
> uses the startup servlet's connection pool to do some cleaning up by
> accessing the legacy system. This is fine but when I manually shutdown the
> server (Tomcat 3.1), the server invalidates the user sessions but this
> occurs after the destroy() method of my startup servlet is called which in
> effect makes the system calls to the valueUnbound() method of my class try
> and grab a resource which doesn't exist anymore in the ServletContext.
>
> What I want to do is have the destroy() method wait until all the
> HttpSession objects have been invalidated and then and only then clean up
> the connection pool. I can't seem to find anyway to access any information
> about server wide HttpSession's. Anyone have any ideas on how to do this??
>
Even if Tomcat were modified to change this order (which is what you
would have
to do to change this behavior), you would not be able to count on things
working
in other servlet containers -- because the order of these calls is not
defined
in the servlet 2.2 spec.
For the next version of the servlet spec, work is underway to define
"application event handlers" that are designed to meet the need for
being able
to gracefully initialize and finalize shared resources like this, and
"session
event handlers" that can be used for session cleanup without the need
for
HttpSessionBindingListener (although that will still be available).
>
> Thanks,
>
> Mike
>
Craig McClanahan
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html