Author: dkulp Date: Fri Oct 16 22:04:37 2009 New Revision: 826105 URL: http://svn.apache.org/viewvc?rev=826105&view=rev Log: Merged revisions 826102 via svnmerge from https://svn.apache.org/repos/asf/cxf/branches/2.2.x-fixes
................ r826102 | dkulp | 2009-10-16 17:47:33 -0400 (Fri, 16 Oct 2009) | 9 lines Merged revisions 826098 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r826098 | dkulp | 2009-10-16 17:40:08 -0400 (Fri, 16 Oct 2009) | 1 line [CXF-2283] if a Child context is closed, we shouldn't be shutting down ........ ................ Added: cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/child.xml - copied unchanged from r826102, cxf/branches/2.2.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/child.xml Modified: cxf/branches/2.1.x-fixes/ (props changed) cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java Propchange: cxf/branches/2.1.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java?rev=826105&r1=826104&r2=826105&view=diff ============================================================================== --- cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java (original) +++ cxf/branches/2.1.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/BusApplicationListener.java Fri Oct 16 22:04:37 2009 @@ -42,18 +42,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/branches/2.1.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java?rev=826105&r1=826104&r2=826105&view=diff ============================================================================== --- cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java (original) +++ cxf/branches/2.1.x-fixes/rt/frontend/jaxws/src/test/java/org/apache/cxf/jaxws/spring/SpringBeansTest.java Fri Oct 16 22:04:37 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.databinding.DataBinding; import org.apache.cxf.databinding.source.SourceDataBinding; import org.apache.cxf.endpoint.Client; @@ -225,6 +227,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"});
