Re: using finalize() to persist objects
From: John C. Bollinger (jobollin_at_indiana.edu)
Date: 02/07/05
- Next message: mikelinyoho_at_gmail.com: "Re: Could someone good to see the programming archtecture?"
- Previous message: Alessandro Angeli [MVP::DigitalMedia]: "Re: Java - C# interop"
- In reply to: GregSmith: "Re: using finalize() to persist objects"
- Next in thread: John C. Bollinger: "Re: using finalize() to persist objects"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 07 Feb 2005 11:33:35 -0500
GregSmith wrote:
> The Java Servler Whitepaper
> (http://java.sun.com/products/servlet/whitepaper.html) Says...
>
> "<i>Requests are processed until the servlet is explicitly shut down by
> the web server, by calling the destroy method. The servlet's class may
> then become eligible for garbage collection. </i>"
>
> So, you should be able to serialize in the destroy() method.
No, he can't. The servlet container is free at any time to destroy() a
servlet instance and replace it with a new instance of the same servlet
class. It could even delay creating the new instance until a request is
received that maps to that servlet. In the case of a servlet that
implements SingleThreadModel, the container is even free to maintain
multiple instances concurrently, in which case it would be completely
incorrect to serialize in the servlet's destroy() method.
The servlet API defines a means for a web application to receive
notification when it is being shut down (the ServletContextListener; see
my other response). If shutdown notification is what is desired then
that API should be used, not some hack that may (or may not) be found to
work under the initial development conditions.
-- John Bollinger jobollin@indiana.edu
- Next message: mikelinyoho_at_gmail.com: "Re: Could someone good to see the programming archtecture?"
- Previous message: Alessandro Angeli [MVP::DigitalMedia]: "Re: Java - C# interop"
- In reply to: GregSmith: "Re: using finalize() to persist objects"
- Next in thread: John C. Bollinger: "Re: using finalize() to persist objects"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|