I need to do some cleanup when guice servlet is removed. Is it possible to hook into the servlet destruction when using a guice servlet? I need to use the Injector to do the cleanup work.
I can override the contextDestroyed
method in GuiceServletContextListener
, but then how do I get access to the injector?
Is there a better way to react to servlet destruction?
You could do it like this:
Or like this: