Greg Trasuk at [EMAIL PROTECTED] wrote:

> Hi all:
> 
> Yes, a good discussion.
> 
> I puzzled over this for an application I wrote a while ago.  After many
> hours contemplating the servlet spec (2.2), I finally decided that if I
> created an object and dropped it into the application context, it was
> guaranteed to live as long as the servlet container.  My logic was this:
> - The servlet container can load/unload servlets at its pleasure
> - A servlet marked "Load-on-startup" will be loaded and have its init()
> method called when the container starts, even if its not mapped to a URL.
> - Java won't finalize an instance so long as another instance or class has
> a reference to it.
> - The application context will maintain a reference to the instance.
> - If the servlet container destroys the application context, it's probably
> a sign that I should reinitialize everything anyway.
> 
> Could some of the folks who are more familiar with the specs and
> implementation comment on whether this logic is correct and portable to all
> containers?  It worked for the application under Tomcat 3.x, but I've always
> had nagging doubts.

All YES but the last two... You cannot be guaranteed that the container will
maintain a reference until it dies... BUT at the same time, I haven't seen
anyone doing the contrary...


    Pier

Reply via email to