Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BE6CB10D07 for ; Tue, 21 Jan 2014 11:47:00 +0000 (UTC) Received: (qmail 93013 invoked by uid 500); 21 Jan 2014 11:46:59 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 92887 invoked by uid 500); 21 Jan 2014 11:46:57 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 92876 invoked by uid 99); 21 Jan 2014 11:46:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jan 2014 11:46:56 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 21 Jan 2014 11:46:54 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 6713D238883D; Tue, 21 Jan 2014 11:46:33 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1559985 - in /cxf/trunk/core/src: main/java/org/apache/cxf/bus/spring/SpringBus.java test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java Date: Tue, 21 Jan 2014 11:46:33 -0000 To: commits@cxf.apache.org From: ningjiang@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20140121114633.6713D238883D@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ningjiang Date: Tue Jan 21 11:46:32 2014 New Revision: 1559985 URL: http://svn.apache.org/r1559985 Log: CXF-5505 SpringBus should shutdown the bus when the application context is closed Modified: cxf/trunk/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java cxf/trunk/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java Modified: cxf/trunk/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java URL: http://svn.apache.org/viewvc/cxf/trunk/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java?rev=1559985&r1=1559984&r2=1559985&view=diff ============================================================================== --- cxf/trunk/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java (original) +++ cxf/trunk/core/src/main/java/org/apache/cxf/bus/spring/SpringBus.java Tue Jan 21 11:46:32 2014 @@ -20,7 +20,6 @@ package org.apache.cxf.bus.spring; import org.apache.cxf.bus.extension.ExtensionManagerBus; -import org.apache.cxf.buslifecycle.BusLifeCycleManager; import org.apache.cxf.configuration.ConfiguredBeanLocator; import org.apache.cxf.configuration.Configurer; import org.apache.cxf.configuration.spring.ConfigurerImpl; @@ -108,8 +107,10 @@ public class SpringBus extends Extension if (getState() != BusState.RUNNING) { initialize(); } - } else if (event instanceof ContextClosedEvent) { - getExtension(BusLifeCycleManager.class).postShutdown(); + } else if (event instanceof ContextClosedEvent && getState() == BusState.RUNNING) { + // The bus could be create by using SpringBusFactory.createBus("/cxf.xml"); + // Just to make sure the shutdown is called rightly + shutdown(); } } } Modified: cxf/trunk/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java URL: http://svn.apache.org/viewvc/cxf/trunk/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java?rev=1559985&r1=1559984&r2=1559985&view=diff ============================================================================== --- cxf/trunk/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java (original) +++ cxf/trunk/core/src/test/java/org/apache/cxf/bus/spring/SpringBusFactoryTest.java Tue Jan 21 11:46:32 2014 @@ -96,6 +96,14 @@ public class SpringBusFactoryTest extend } @Test + public void testCustomerBusShutdown() { + String cfgFile = "org/apache/cxf/bus/spring/customerBus.xml"; + Bus bus = new SpringBusFactory().createBus(cfgFile, true); + // We have three bus here, which should be closed rightly + bus.shutdown(true); + } + + @Test public void testCustomFileURLFromSystemProperty() { URL cfgFileURL = this.getClass().getResource("resources/bus-overwrite.xml"); System.setProperty(Configurer.USER_CFG_FILE_PROPERTY_URL, cfgFileURL.toString());