Hey, How about an HttpSessionListener? I'm not sure if HttpSessionListener.contextDestroyed is invoked on shutdownthough. Probably not...
I'm afraid the only option is custom bookkeeping, maybe using an HttpSessionListener/ServletContextListener to publish events to the Registry. I see some issues with this approach: 1 Configuration becomes more difficult for the application developer, because these two Listeners become required configuration. 2 Managing objects yourself may be tricky business. An option could be to use WeakReference/WeakHashMap for this so you don't accidentally keep your objects alive. 3 What to do with regards to session replication on a clustered environment? I'm not sure this will become an issue, but it wouldn't surprise me if it will. Regards, Jan-Kees 2010/1/13 Jakob Korherr <[email protected]>: > Hi guys, > > To ensure the execution of the ManagedBean's @PreDestroy methods on a > container shutdown/restart, I would like to introduce a ManagedBeanRegistry, > in which all active ManagedBeans from all scopes are referenced. > > The problem is the following: At the moment on a container shutdown or > restart, only contextDestroyed is invoked (tested in tomcat 6), thus only > the @PreDestroy methods of all ApplicationScoped ManagedBeans will be > invoked, but not those of any existing ManagedBeans in session, request, > view (and maybe also custom) scope, because they can not be referenced in > contextDestroyed(). > > Any opinions on that? > > Thanks in advance! > > Regards, > Jakob >
