On Sat, Mar 7, 2009 at 5:42 AM, Endre Stølsvik <[email protected]> wrote:

>
> On Fri, Mar 6, 2009 at 02:07, Dhanji R. Prasanna <[email protected]> wrote:
> >
>
> As I said, no servlet container I know of actually use this, but the
> spec (v.2.5) states:
> SRV.2.3.4:
>  " The servlet container is not required to keep a servlet loaded for
> any particular period of time. A servlet instance may be kept active
> in a servlet container for a period of milliseconds, for the lifetime
> of  the servlet container (which could be a number of days, months, or
> years), or any amount of time in between. When the servlet container
> determines that a servlet should be removed from service, it calls the
> destroy method of the Servlet interface to allow the servlet to
> release any resources it is using and save any persistent state. For
> example, the container may do this when it wants to conserve memory
> resources, or when it is being shut down."
>
> To bad if that particular servlet's destroy method takes down your
> database, right?


That section was written in the context of SingleThreadModel, which allows
servlets to be pooled (in effect "no-scoped").  It is absurd to think that a
servlet container will destroy singleton servlets in order to conserve
memory.

I'll see if we can update that language in the specification.


> Thus, before the introduction of the ServletContextListener, there was
> really not any proper way to have application lifecycle. This is
> probably why no servlet container takes down a specific Servlet except
> when shutting down the entire app (something it obviously does when
> redeploying an app), as everybody ended up using init and destroy on
> the servlets to make app lifecycle (employing the load-on-startup
> attribute to get the app up when the container went up).
>
> But it is still not the correct way to do app lifecycle, spec-wise,
> IIUC. If I made a servlet framework, I'd take that into consideration.


Yea I've heard this argument before. I don't think it has much merit since
the only way to share resources is through the ServletContext or JNDI.
Neither of which are very good options.

All this was made with a cluster-agnostic programming model in mind. In
practice nobody has really used it this way, however.


> SRV.10.1
>  " The application events facility gives the Web Application
> Developer greater control over the lifecycle of the ServletContext and
> HttpSession and ServletRequest, allows for better code factorization,
> and increases efficiency in managing the resources that the Web
> application uses. "


I think a more compelling use case to be made here is that the
ServletContextListener fires predictably, whereas init() is typically fired
lazily (Tomcat for instance uses a DCL to achieve this).

In GS2 we provide the option to do either, with
GuiceServletContextListener.

Dhanji.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/google-guice?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to