Return-Path: Delivered-To: apmail-incubator-cxf-commits-archive@locus.apache.org Received: (qmail 71067 invoked from network); 19 Sep 2007 23:59:47 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 19 Sep 2007 23:59:47 -0000 Received: (qmail 72355 invoked by uid 500); 19 Sep 2007 23:59:38 -0000 Delivered-To: apmail-incubator-cxf-commits-archive@incubator.apache.org Received: (qmail 72303 invoked by uid 500); 19 Sep 2007 23:59:38 -0000 Mailing-List: contact cxf-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: cxf-dev@incubator.apache.org Delivered-To: mailing list cxf-commits@incubator.apache.org Received: (qmail 72294 invoked by uid 99); 19 Sep 2007 23:59:38 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Sep 2007 16:59:38 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Sep 2007 23:59:46 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id E77341A9832; Wed, 19 Sep 2007 16:59:25 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r577477 - /incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java Date: Wed, 19 Sep 2007 23:59:25 -0000 To: cxf-commits@incubator.apache.org From: ningjiang@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20070919235925.E77341A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ningjiang Date: Wed Sep 19 16:59:24 2007 New Revision: 577477 URL: http://svn.apache.org/viewvc?rev=577477&view=rev Log: CXF-1034 shutdown the JettyEngine when bus shutdown is called Modified: incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java Modified: incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java?rev=577477&r1=577476&r2=577477&view=diff ============================================================================== --- incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java (original) +++ incubator/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java Wed Sep 19 16:59:24 2007 @@ -30,6 +30,8 @@ import javax.annotation.Resource; import org.apache.cxf.Bus; +import org.apache.cxf.buslifecycle.BusLifeCycleListener; +import org.apache.cxf.buslifecycle.BusLifeCycleManager; import org.apache.cxf.common.logging.LogUtils; import org.apache.cxf.configuration.jsse.TLSServerParameters; @@ -42,31 +44,19 @@ * caches the JettyHTTPServerEngines so that they may be * retrieved if already previously configured. */ -public class JettyHTTPServerEngineFactory { +public class JettyHTTPServerEngineFactory implements BusLifeCycleListener { private static final Logger LOG = LogUtils.getL7dLogger(JettyHTTPServerEngineFactory.class); /** * This map holds references for allocated ports. */ - // All system tests do not shut down bus correctly, - // or the bus does not shutdown all endpoints correctly, - // so that these server endings are actuall shared amongst busses - // within the same JVM. - - // We will keep it static until we can resolve the problems - // in the System tests. - // TODO: Fix the System Tests so that they shutdown the - // buses that they are using and that the buses actually - // shutdown the destinations and their server engines - // properly. This will require a bit of lifecyle and reference - // counting on Destinations to server engines, if they are - // going to be shared, but they should by no means be - // shared accross buses, right? + // Still use the static map to hold the port information + // in the same JVM private static Map portMap = new HashMap(); - + private BusLifeCycleManager lifeCycleManager; /** * This map holds the threading parameters that are to be applied * to new Engines when bound to the reference id. @@ -89,7 +79,8 @@ public JettyHTTPServerEngineFactory() { // Empty - } + } + /** * This call is used to set the bus. It should only be called once. @@ -104,7 +95,13 @@ @PostConstruct public void registerWithBus() { - bus.setExtension(this, JettyHTTPServerEngineFactory.class); + if (bus != null) { + bus.setExtension(this, JettyHTTPServerEngineFactory.class); + } + lifeCycleManager = bus.getExtension(BusLifeCycleManager.class); + if (null != lifeCycleManager) { + lifeCycleManager.registerLifeCycleListener(this); + } } @@ -200,6 +197,29 @@ @PostConstruct public void finalizeConfig() { registerWithBus(); + } + + public void initComplete() { + // do nothing here + + } + + public void postShutdown() { + // clean up the collections + portMap.clear(); + threadingParametersMap.clear(); + tlsParametersMap.clear(); + } + + public void preShutdown() { + // shut down the jetty server in the portMap + // To avoid the CurrentModificationException, + // do not use portMap.vaules directly + + JettyHTTPServerEngine[] engines = portMap.values().toArray(new JettyHTTPServerEngine[0]); + for (JettyHTTPServerEngine engine : engines) { + engine.shutdown(); + } } }