struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: UML Diagrams for Struts
Date Thu, 02 Nov 2000 17:41:40 GMT
Seth Ladd wrote:

> > Here's a class diagram I draw some days ago. Feel free to criticize it. I
> > can provide you with the Visio 2000 file if you want.
> Thanks so much for taking the time to create the diagram.  I really
> appreciate it.  One question I had for you, though, is where the
> StartUpServlet comes from.  I am assuming that it is a custom servlet you
> had created to initialize the webapp?  I have the same problem: how to
> initialize the app (building connection pool, find EJBs, etc).  Has anyone
> else given this any thought?  One solution would be to specify a startup
> class in the actions.xml file.  This class implements init() which is
> basically called by the ActionServlet's init().  Any ideas?

Application initialization is a little bit clumsy under servlet versions <
2.3.  The solution I chose in the Struts example application was to create a
separate servlet (DatabaseServlet) that fulfills the role of the startup
servlet in the diagram, and then made sure that it is marked <load-on-startup>
in the web.xml file.  That way, it will get loaded before requests are
processed, and can initialize global resources, storing them as servlet context
attributes to make them visible to the rest of the app.

The clumsy part of this, though, is that I put the code to gracefully close
these connections in the destroy() method of DatabaseServlet, based on the
assumption that the servlet container will not actually remove this servlet
while the app is running.  That is true for many / most servlet containers
today, but is not guaranteed.

Under the new Servlet 2.3 spec, however, there is a new feature -- application
events -- that is designed to deal with this situation gracefully.  You can
register (in web.xml) a listener class that is notified when the application is
started, and when it is shut down.  This is a perfect place to do
initialization and finalization type activities.

> Thanks,
> Seth

Craig McClanahan

View raw message