cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1311408 - in /cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet: CXFNonSpringServlet.java CXFServlet.java
Date Mon, 09 Apr 2012 20:07:44 GMT
Author: dkulp
Date: Mon Apr  9 20:07:44 2012
New Revision: 1311408

URL: http://svn.apache.org/viewvc?rev=1311408&view=rev
Log:
[CXF-4127] Make sure the bus and such is reset on ApplicationRefresh

Modified:
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java?rev=1311408&r1=1311407&r2=1311408&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java
Mon Apr  9 20:07:44 2012
@@ -154,6 +154,7 @@ public class CXFNonSpringServlet extends
     public void destroyBus() {
         if (bus != null) {
             bus.shutdown(true);
+            bus = null;
         }
     }
 }

Modified: cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java?rev=1311408&r1=1311407&r2=1311408&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
Mon Apr  9 20:07:44 2012
@@ -22,15 +22,20 @@ import java.io.IOException;
 import java.io.InputStream;
 
 import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
 import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationListener;
+import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.core.io.Resource;
 import org.springframework.web.context.support.WebApplicationContextUtils;
 import org.springframework.web.context.support.XmlWebApplicationContext;
 
-public class CXFServlet extends CXFNonSpringServlet {
+public class CXFServlet extends CXFNonSpringServlet
+    implements ApplicationListener<ContextRefreshedEvent> {
     private static final long serialVersionUID = -5922443981969455305L;
     private boolean busCreated;
     private XmlWebApplicationContext createdContext; 
@@ -42,6 +47,11 @@ public class CXFServlet extends CXFNonSp
     protected void loadBus(ServletConfig sc) {
         ApplicationContext wac = WebApplicationContextUtils.
             getWebApplicationContext(sc.getServletContext());
+        
+        if (wac instanceof AbstractApplicationContext) {
+            ((AbstractApplicationContext)wac).getApplicationListeners().add(this);
+        }
+        
         String configLocation = sc.getInitParameter("config-location");
         if (configLocation == null) {
             try {
@@ -124,10 +134,21 @@ public class CXFServlet extends CXFNonSp
         if (busCreated) {
             //if we created the Bus, we need to destroy it.  Otherwise, spring will handleit.
             getBus().shutdown(true);
+            setBus(null);
         }
         if (createdContext != null) {
             createdContext.close();
         }
     }
 
+    public void onApplicationEvent(ContextRefreshedEvent event) {
+        destroy();
+        setBus(null);
+        try {
+            init(getServletConfig());
+        } catch (ServletException e) {
+            throw new RuntimeException("Unable to reinitialize the CXFServlet", e);
+        }
+    }
+
 }



Mime
View raw message