cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r826098 - in /cxf/trunk/rt: core/src/main/java/org/apache/cxf/bus/spring/ frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/
Date Fri, 16 Oct 2009 21:40:09 GMT
Author: dkulp
Date: Fri Oct 16 21:40:08 2009
New Revision: 826098

URL: http://svn.apache.org/viewvc?rev=826098&view=rev
Log:
[CXF-2283] if a Child context is closed, we shouldn't be shutting down

Added:
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/child.xml   (with
props)
Modified:
    cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/ClientHolderBean.java
    cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java

Modified: cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java?rev=826098&r1=826097&r2=826098&view=diff
==============================================================================
--- cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java
(original)
+++ cxf/trunk/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java
Fri Oct 16 21:40:08 2009
@@ -44,18 +44,29 @@
         if (ctx == null) {
             return;
         }
-        if (event instanceof ContextRefreshedEvent) {
-            Bus bus = (Bus)ctx.getBean("cxf");
-            ((CXFBusImpl)bus).initialize();
-            BusLifeCycleManager lcm = (BusLifeCycleManager)
-                ctx.getBean("org.apache.cxf.buslifecycle.BusLifeCycleManager",
+        boolean doIt = false;
+        ApplicationContext ac = ctx;
+        while (ac != null && !doIt) {
+            if (event.getSource() == ac) {
+                doIt = true;
+            }
+            ac = ac.getParent();
+        }
+        
+        if (doIt) {
+            if (event instanceof ContextRefreshedEvent) {
+                Bus bus = (Bus)ctx.getBean("cxf");
+                ((CXFBusImpl)bus).initialize();
+                BusLifeCycleManager lcm = (BusLifeCycleManager)
+                    ctx.getBean("org.apache.cxf.buslifecycle.BusLifeCycleManager",
+                            BusLifeCycleManager.class);
+                lcm.initComplete();
+            } else if (event instanceof ContextClosedEvent) {
+                BusLifeCycleManager lcm = (BusLifeCycleManager)
+                    ctx.getBean("org.apache.cxf.buslifecycle.BusLifeCycleManager",
                         BusLifeCycleManager.class);
-            lcm.initComplete();
-        } else if (event instanceof ContextClosedEvent) {
-            BusLifeCycleManager lcm = (BusLifeCycleManager)
-                ctx.getBean("org.apache.cxf.buslifecycle.BusLifeCycleManager",
-                    BusLifeCycleManager.class);
-            lcm.postShutdown();
+                lcm.postShutdown();
+            }
         }
     }
 

Modified: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/ClientHolderBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/ClientHolderBean.java?rev=826098&r1=826097&r2=826098&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/ClientHolderBean.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/ClientHolderBean.java
Fri Oct 16 21:40:08 2009
@@ -28,7 +28,7 @@
  */
 public class ClientHolderBean {
 
-    @Autowired(required = true)
+    @Autowired
     Collection<org.apache.hello_world_soap_http.Greeter> greeters;
     
     org.apache.hello_world_soap_http.Greeter greet1;

Modified: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java?rev=826098&r1=826097&r2=826098&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java
Fri Oct 16 21:40:08 2009
@@ -37,6 +37,8 @@
 import org.apache.cxf.binding.soap.SoapBindingConfiguration;
 import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor;
 import org.apache.cxf.binding.soap.saaj.SAAJOutInterceptor;
+import org.apache.cxf.buslifecycle.BusLifeCycleListener;
+import org.apache.cxf.buslifecycle.BusLifeCycleManager;
 import org.apache.cxf.configuration.spring.AbstractFactoryBeanDefinitionParser;
 import org.apache.cxf.databinding.DataBinding;
 import org.apache.cxf.databinding.source.SourceDataBinding;
@@ -209,6 +211,37 @@
     }
 
     @Test
+    public void testChildContext() throws Exception {
+        //Test for CXF-2283 - if a Child context is closed,
+        //we shouldn't be shutting down
+        ClassPathXmlApplicationContext ctx =
+            new ClassPathXmlApplicationContext(new String[] {"/org/apache/cxf/jaxws/spring/servers.xml"});
+        
+        final Bus b = (Bus)ctx.getBean("cxf");
+        BusLifeCycleManager lifeCycleManager = b.getExtension(BusLifeCycleManager.class);
+        BusLifeCycleListener listener = new BusLifeCycleListener() {
+            public void initComplete() {
+            }
+
+            public void postShutdown() {
+                b.setProperty("post.was.called", Boolean.TRUE);
+            }
+
+            public void preShutdown() {
+                b.setProperty("pre.was.called", Boolean.TRUE);
+            }
+        };
+        lifeCycleManager.registerLifeCycleListener(listener);
+        ClassPathXmlApplicationContext ctx2 =
+                new ClassPathXmlApplicationContext(new String[] {"/org/apache/cxf/jaxws/spring/child.xml"},
+                                                   ctx);
+        
+        ctx2.close();
+        
+        assertNull(b.getProperty("post.was.called"));
+        assertNull(b.getProperty("pre.was.called"));
+    }
+    @Test
     public void testServers() throws Exception {
         ClassPathXmlApplicationContext ctx =
             new ClassPathXmlApplicationContext(new String[] {"/org/apache/cxf/jaxws/spring/servers.xml"});

Added: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/child.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/child.xml?rev=826098&view=auto
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/child.xml (added)
+++ cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/child.xml Fri Oct
16 21:40:08 2009
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+      xmlns:jaxws="http://cxf.apache.org/jaxws"
+      xmlns:soap="http://cxf.apache.org/bindings/soap"
+      xsi:schemaLocation="
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
+http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd
+http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> 
+
+
+	<bean class="org.apache.cxf.jaxws.spring.NullInvoker"/>
+	<bean class="org.apache.cxf.jaxws.spring.ClientHolderBean"/>
+
+</beans>
\ No newline at end of file

Propchange: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/child.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/child.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: cxf/trunk/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/child.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message