cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1311424 - in /cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet: CXFNonSpringServlet.java CXFServlet.java
Date Mon, 09 Apr 2012 20:33:43 GMT
Author: dkulp
Date: Mon Apr  9 20:33:43 2012
New Revision: 1311424

URL: http://svn.apache.org/viewvc?rev=1311424&view=rev
Log:
Merged revisions 1311408 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk

........
  r1311408 | dkulp | 2012-04-09 16:07:44 -0400 (Mon, 09 Apr 2012) | 2 lines

  [CXF-4127] Make sure the bus and such is reset on ApplicationRefresh

........

Modified:
    cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java
    cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java

Modified: cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java?rev=1311424&r1=1311423&r2=1311424&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFNonSpringServlet.java
Mon Apr  9 20:33:43 2012
@@ -153,6 +153,7 @@ public class CXFNonSpringServlet extends
     public void destroyBus() {
         if (bus != null) {
             bus.shutdown(true);
+            bus = null;
         }
     }
 }

Modified: cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java?rev=1311424&r1=1311423&r2=1311424&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
Mon Apr  9 20:33:43 2012
@@ -22,15 +22,21 @@ 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; 
     
@@ -41,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 {
@@ -123,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