Markus Holzem wrote:
I usually story Singletons in the ServletContext which is unique for an application. I often think that ServletContext should be better named ApplicationContext because that is actually what it represents.
I don't feel comfortable to leave Singletons hanging around on static. variables. The benefit of ServletContext is, that you can easily participate on the lifecycle of the ServletContext (ServletContextListener::contextInitialized and ~::contextDestroyed) and take appropriate actions when your Singleton acquires any system resources.
That's a good point, but even better (IMHO), if your model does not use any controller-specific resources (makes for easier unit testing too), is to combine the two. In other words, *do* use the traditional Singleton on a static variable, but also *do* provide a static method for destroying the singleton which is then called by the contextDestroyed method.
I just thought of that now so there could be repercussions I hadn't considered.
Erik
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

