Author: carlucci
Date: Tue Jul 10 19:54:07 2012
New Revision: 1359862
URL: http://svn.apache.org/viewvc?rev=1359862&view=rev
Log:
RAVE-722: Shindig webapp component can't be re-deployed without a container
restart
Modified:
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/main/java/org/apache/rave/inject/GuiceBindingSpringContextLoaderListener.java
Modified:
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/main/java/org/apache/rave/inject/GuiceBindingSpringContextLoaderListener.java
URL:
http://svn.apache.org/viewvc/rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/main/java/org/apache/rave/inject/GuiceBindingSpringContextLoaderListener.java?rev=1359862&r1=1359861&r2=1359862&view=diff
==============================================================================
---
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/main/java/org/apache/rave/inject/GuiceBindingSpringContextLoaderListener.java
(original)
+++
rave/trunk/rave-providers/rave-opensocial-provider/rave-opensocial-core/src/main/java/org/apache/rave/inject/GuiceBindingSpringContextLoaderListener.java
Tue Jul 10 19:54:07 2012
@@ -46,6 +46,26 @@ public class GuiceBindingSpringContextLo
overrideInjector(Guice.createInjector(modules), servletContext);
}
+ /**
+ * Clean up code that should run when the servlet context is destroyed
+ *
+ * @param event
+ */
+ @Override
+ public void contextDestroyed(ServletContextEvent event) {
+ ServletContext context = event.getServletContext();
+ // grab the Guice Injector object from the Servlet Context
+ Injector injector = (Injector)
context.getAttribute(GuiceServletContextListener.INJECTOR_ATTRIBUTE);
+ if (injector != null) {
+ // invoke the cleanup function for all Guice modules that
implement the CleanupCapable interface
+ // this will do things like remove MBeans that might be registered
to the JVM
+ GuiceServletContextListener.CleanupHandler cleanups =
injector.getInstance(GuiceServletContextListener.CleanupHandler.class);
+ cleanups.cleanup();
+ }
+
+
context.removeAttribute(GuiceServletContextListener.INJECTOR_ATTRIBUTE);
+ }
+
private static void overrideInjector(Injector injector, ServletContext
context) {
context.setAttribute(GuiceServletContextListener.INJECTOR_ATTRIBUTE,
injector);
}