cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r935055 - in /cxf/trunk/rt: frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/ frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ transports/http/src/main/java/org/apache/cxf/transport/servlet/
Date Fri, 16 Apr 2010 19:33:18 GMT
Author: dkulp
Date: Fri Apr 16 19:33:18 2010
New Revision: 935055

URL: http://svn.apache.org/viewvc?rev=935055&view=rev
Log:
[CXF-2730] For spring 3, make sure the servlet is registered as a
listener that will survive a refresh
Also make sure destroy is called on servers using simple:server and
jaxws:server

Modified:
    cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/NamespaceHandler.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java

Modified: cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/NamespaceHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/NamespaceHandler.java?rev=935055&r1=935054&r2=935055&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/NamespaceHandler.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/java/org/apache/cxf/jaxws/spring/NamespaceHandler.java
Fri Apr 16 19:33:18 2010
@@ -52,7 +52,12 @@ public class NamespaceHandler extends Na
         public SpringServerFactoryBean(JaxWsServiceFactoryBean fact) {
             super(fact);
         }
-
+        public void destroy() {
+            if (getServer() != null) {
+                getServer().destroy();
+                setServer(null);
+            }
+        }
         public void setApplicationContext(ApplicationContext ctx) throws BeansException {
             if (getBus() == null) {
                 Bus bus = BusFactory.getThreadDefaultBus();

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java?rev=935055&r1=935054&r2=935055&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
(original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/spring/ServerFactoryBeanDefinitionParser.java
Fri Apr 16 19:33:18 2010
@@ -88,6 +88,7 @@ public class ServerFactoryBeanDefinition
         super.doParse(element, ctx, bean);
 
         bean.setInitMethodName("create");
+        bean.setDestroyMethodName("destroy");
         
         // We don't really want to delay the registration of our Server
         bean.setLazyInit(false);
@@ -121,7 +122,13 @@ public class ServerFactoryBeanDefinition
         public SpringServerFactoryBean(ReflectionServiceFactoryBean fact) {
             super(fact);
         }
-        
+        public void destroy() {
+            if (getServer() != null) {
+                getServer().destroy();
+                setServer(null);
+            }
+        }
+
         public void setApplicationContext(ApplicationContext ctx) throws BeansException {
             if (getBus() == null) {
                 Bus bus = BusFactory.getThreadDefaultBus();

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=935055&r1=935054&r2=935055&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
Fri Apr 16 19:33:18 2010
@@ -22,6 +22,7 @@ package org.apache.cxf.transport.servlet
 import java.io.IOException;
 import java.io.InputStream;
 
+import java.util.Collection;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -34,6 +35,7 @@ import org.apache.cxf.bus.spring.BusAppl
 import org.apache.cxf.bus.spring.SpringBusFactory;
 import org.apache.cxf.common.classloader.ClassLoaderUtils;
 import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.helpers.CastUtils;
 import org.apache.cxf.resource.ResourceManager;
 import org.apache.cxf.resource.URIResolver;
 import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
@@ -42,6 +44,7 @@ import org.springframework.context.Appli
 import org.springframework.context.ApplicationListener;
 import org.springframework.context.ConfigurableApplicationContext;
 import org.springframework.context.event.ContextRefreshedEvent;
+import org.springframework.context.support.AbstractApplicationContext;
 import org.springframework.context.support.GenericApplicationContext;
 import org.springframework.core.io.InputStreamResource;
 
@@ -103,7 +106,23 @@ public class CXFServlet extends Abstract
         if (ctx instanceof ConfigurableApplicationContext) {
             ((ConfigurableApplicationContext)ctx).addApplicationListener(this);
         }
+        if (ctx instanceof AbstractApplicationContext) {
+            Collection<ApplicationListener> lst = getListeners(ctx);
+            if (lst != null && !lst.contains(this)) {
+                lst.add(this);
+            }
+        }
+    }
+    private Collection<ApplicationListener> getListeners(ApplicationContext ctx) {
+        try {
+            Object o = ctx.getClass().getMethod("getApplicationListeners").invoke(ctx);
+            return CastUtils.cast((Collection<?>)o);
+        } catch (Exception e) {
+            //ignore
+        }
+        return null;
     }
+    
     private void updateContext(ServletConfig servletConfig, ApplicationContext ctx) {
         /* If ctx is null, normally no ContextLoaderListener 
          * was defined in web.xml.  Default bus with all extensions



Mime
View raw message