Return-Path: Delivered-To: apmail-incubator-cxf-dev-archive@locus.apache.org Received: (qmail 88721 invoked from network); 20 Sep 2007 00:45:05 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 20 Sep 2007 00:45:05 -0000 Received: (qmail 93177 invoked by uid 500); 20 Sep 2007 00:44:56 -0000 Delivered-To: apmail-incubator-cxf-dev-archive@incubator.apache.org Received: (qmail 93121 invoked by uid 500); 20 Sep 2007 00:44:56 -0000 Mailing-List: contact cxf-dev-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-dev@incubator.apache.org Received: (qmail 93110 invoked by uid 99); 20 Sep 2007 00:44:56 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 19 Sep 2007 17:44:56 -0700 X-ASF-Spam-Status: No, hits=3.2 required=10.0 tests=RCVD_IN_BL_SPAMCOP_NET,SPF_HELO_PASS,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (nike.apache.org: local policy) Received: from [64.79.194.121] (HELO mesa2.com) (64.79.194.121) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 20 Sep 2007 00:46:50 +0000 Received: from [24.147.10.180] (account jdkulp HELO dilbert.boston.amer.iona.com) by mesa2.com (CommuniGate Pro SMTP 4.1.8) with ESMTP id 1328696 for cxf-dev@incubator.apache.org; Wed, 19 Sep 2007 20:44:28 -0400 From: Daniel Kulp To: cxf-dev@incubator.apache.org Subject: Re: 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 20:44:27 -0400 User-Agent: KMail/1.9.7 References: <20070919235925.E77341A9832@eris.apache.org> In-Reply-To: <20070919235925.E77341A9832@eris.apache.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200709192044.28132.dkulp@apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Willem, I think this commit will cause more problems. With this commit, if you have two busses in your application with services registered in each, if you shutdown one bus, all the services get killed. We definitely don't want that. Basically, the engine needs to track how many services are registered on a port, and when that drops to 0, then possibly shutdown. Dan On Wednesday 19 September 2007, ningjiang@apache.org wrote: > 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-je >tty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEn >gineFactory.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(); > + } > } > > } -- J. Daniel Kulp Principal Engineer IONA P: 781-902-8727 C: 508-380-7194 daniel.kulp@iona.com http://www.dankulp.com/blog