cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1325343 - in /cxf/trunk: rt/core/src/main/java/org/apache/cxf/bus/spring/ rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ testutils/src/main/java/org/apache/cxf/testutil/common/
Date Thu, 12 Apr 2012 16:09:54 GMT
Author: dkulp
Date: Thu Apr 12 16:09:53 2012
New Revision: 1325343

URL: http://svn.apache.org/viewvc?rev=1325343&view=rev
Log:
Fix some spring2 compat issues

Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/CXFServlet.java
    cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractBusTestServerBase.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java?rev=1325343&r1=1325342&r2=1325343&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java (original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusDefinitionParser.java Thu
Apr 12 16:09:53 2012
@@ -96,7 +96,7 @@ public class BusDefinitionParser extends
     private void copyProps(BeanDefinitionBuilder src, BeanDefinition def) {
         for (PropertyValue v : src.getBeanDefinition().getPropertyValues().getPropertyValues())
{
             if (!"bus".equals(v.getName())) {
-                def.getPropertyValues().add(v.getName(), v.getValue());
+                def.getPropertyValues().addPropertyValue(v.getName(), v.getValue());
             }
             src.getBeanDefinition().getPropertyValues().removePropertyValue(v);
         }

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java?rev=1325343&r1=1325342&r2=1325343&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusWiringBeanFactoryPostProcessor.java
Thu Apr 12 16:09:53 2012
@@ -74,7 +74,7 @@ public class BusWiringBeanFactoryPostPro
             ConfigurableApplicationContext cctx = (ConfigurableApplicationContext)context;
             cctx.getBeanFactory().registerSingleton(name, b);
         }
-        return context.getBean(name, Bus.class);
+        return (Bus)context.getBean(name, Bus.class);
     }
     private Object getBusForName(String name,
                                  ConfigurableListableBeanFactory factory,
@@ -89,7 +89,7 @@ public class BusWiringBeanFactoryPostPro
             df.registerBeanDefinition(name, rbd);
         } else if (cn != null) {
             BeanDefinition bd = factory.getBeanDefinition(name);
-            bd.getPropertyValues().add("busConfig", new RuntimeBeanReference(cn));
+            bd.getPropertyValues().addPropertyValue("busConfig", new RuntimeBeanReference(cn));
         }
         return new RuntimeBeanReference(name);        
     }

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=1325343&r1=1325342&r2=1325343&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
Thu Apr 12 16:09:53 2012
@@ -20,12 +20,16 @@ package org.apache.cxf.transport.servlet
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.lang.reflect.Method;
+import java.util.Collection;
 
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.util.ReflectionUtil;
+import org.apache.cxf.helpers.CastUtils;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationListener;
 import org.springframework.context.event.ContextRefreshedEvent;
@@ -49,7 +53,7 @@ public class CXFServlet extends CXFNonSp
             getWebApplicationContext(sc.getServletContext());
         
         if (wac instanceof AbstractApplicationContext) {
-            ((AbstractApplicationContext)wac).getApplicationListeners().add(this);
+            addListener((AbstractApplicationContext)wac);
         }
         
         String configLocation = sc.getInitParameter("config-location");
@@ -68,13 +72,25 @@ public class CXFServlet extends CXFNonSp
             wac = createSpringContext(wac, sc, configLocation);
         }
         if (wac != null) {
-            setBus(wac.getBean("cxf", Bus.class));
+            setBus((Bus)wac.getBean("cxf", Bus.class));
         } else {
             busCreated = true;
             setBus(BusFactory.newInstance().createBus());
         }
     }
 
+    protected void addListener(AbstractApplicationContext wac) {
+        try {
+            //spring 2 vs spring 3 return type is different
+            Method m = wac.getClass().getMethod("getApplicationListeners");
+            Collection<Object> c = CastUtils.cast((Collection<?>)ReflectionUtil
+                                                      .setAccessible(m).invoke(wac));
+            c.add(this);
+        } catch (Throwable t) {
+            //ignore.
+        }
+    }
+
     /**
      * Try to create a spring application context from the config location.
      * Will first try to resolve the location using the servlet context.

Modified: cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractBusTestServerBase.java
URL: http://svn.apache.org/viewvc/cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractBusTestServerBase.java?rev=1325343&r1=1325342&r2=1325343&view=diff
==============================================================================
--- cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractBusTestServerBase.java
(original)
+++ cxf/trunk/testutils/src/main/java/org/apache/cxf/testutil/common/AbstractBusTestServerBase.java
Thu Apr 12 16:09:53 2012
@@ -28,7 +28,11 @@ public abstract class AbstractBusTestSer
     public boolean stopInProcess() throws Exception {
         boolean ret = super.stopInProcess();
         if (bus != null) {
-            bus.shutdown(true);
+            try {
+                bus.shutdown(true);
+            } catch (Throwable t) {
+                //ignore, we're shutting down
+            }
         }
         return ret;
     }    



Mime
View raw message