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 434327E1F for ; Thu, 28 Jul 2011 21:56:10 +0000 (UTC) Received: (qmail 4949 invoked by uid 500); 28 Jul 2011 21:56:10 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 4866 invoked by uid 500); 28 Jul 2011 21:56:09 -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 4859 invoked by uid 99); 28 Jul 2011 21:56:09 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 28 Jul 2011 21:56:09 +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; Thu, 28 Jul 2011 21:56:07 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 86E0B2388994 for ; Thu, 28 Jul 2011 21:55:47 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1152014 - in /cxf/branches/2.3.x-fixes: ./ rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/ Date: Thu, 28 Jul 2011 21:55:47 -0000 To: commits@cxf.apache.org From: dkulp@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110728215547.86E0B2388994@eris.apache.org> Author: dkulp Date: Thu Jul 28 21:55:45 2011 New Revision: 1152014 URL: http://svn.apache.org/viewvc?rev=1152014&view=rev Log: Merged revisions 1152012 via svnmerge from https://svn.us.apache.org/repos/asf/cxf/branches/2.4.x-fixes ................ r1152012 | dkulp | 2011-07-28 17:46:51 -0400 (Thu, 28 Jul 2011) | 9 lines Merged revisions 1152010 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk ........ r1152010 | dkulp | 2011-07-28 17:40:13 -0400 (Thu, 28 Jul 2011) | 1 line [CXF-3695] Thread safety of Jetty transport ........ ................ Modified: cxf/branches/2.3.x-fixes/ (props changed) cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java Propchange: cxf/branches/2.3.x-fixes/ ------------------------------------------------------------------------------ --- svn:mergeinfo (added) +++ svn:mergeinfo Thu Jul 28 21:55:45 2011 @@ -0,0 +1,2 @@ +/cxf/branches/2.4.x-fixes:1152012 +/cxf/trunk:1152010 Propchange: cxf/branches/2.3.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java?rev=1152014&r1=1152013&r2=1152014&view=diff ============================================================================== --- cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java (original) +++ cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java Thu Jul 28 21:55:45 2011 @@ -68,12 +68,6 @@ public class JettyHTTPServerEngine private static final Logger LOG = LogUtils.getL7dLogger(JettyHTTPServerEngine.class); - - /** - * The bus. - */ - protected Bus bus; - /** * This is the Jetty HTTP Server Engine Factory. This factory caches some * engines based on port numbers. @@ -132,10 +126,8 @@ public class JettyHTTPServerEngine */ public JettyHTTPServerEngine( JettyHTTPServerEngineFactory fac, - Bus bus, String host, int port) { - this.bus = bus; this.factory = fac; this.host = host; this.port = port; @@ -169,15 +161,12 @@ public class JettyHTTPServerEngine * The bus. */ @Resource(name = "cxf") - public void setBus(Bus b) { - bus = b; - } - - public Bus getBus() { - return bus; + public void setBus(Bus bus) { + if (null != bus && null == factory) { + factory = bus.getExtension(JettyHTTPServerEngineFactory.class); + } } - /** * Returns the protocol "http" or "https" for which this engine * was configured. @@ -654,18 +643,11 @@ public class JettyHTTPServerEngine public void finalizeConfig() throws GeneralSecurityException, IOException { - retrieveEngineFactory(); retrieveListenerFactory(); checkConnectorPort(); this.configFinalized = true; } - protected void retrieveEngineFactory() { - if (null != bus && null == factory) { - factory = bus.getExtension(JettyHTTPServerEngineFactory.class); - } - } - private void checkConnectorPort() throws IOException { if (null != connector && port != connector.getPort()) { throw new IOException("Error: Connector port " + connector.getPort() + " does not match" Modified: cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java?rev=1152014&r1=1152013&r2=1152014&view=diff ============================================================================== --- cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java (original) +++ cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java Thu Jul 28 21:55:45 2011 @@ -20,10 +20,10 @@ package org.apache.cxf.transport.http_je import java.io.IOException; import java.security.GeneralSecurityException; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.TreeMap; +import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -57,8 +57,10 @@ public class JettyHTTPServerEngineFactor */ // Still use the static map to hold the port information // in the same JVM - private static Map portMap = - new HashMap(); + private static ConcurrentHashMap portMap = + new ConcurrentHashMap(); + + private BusLifeCycleManager lifeCycleManager; /** @@ -99,6 +101,23 @@ public class JettyHTTPServerEngineFactor setBus(b); } + private static synchronized JettyHTTPServerEngine getOrCreate(JettyHTTPServerEngineFactory factory, + String host, + int port, + TLSServerParameters tlsParams) throws IOException, GeneralSecurityException { + + JettyHTTPServerEngine ref = portMap.get(port); + if (ref == null) { + ref = new JettyHTTPServerEngine(factory, host, port); + if (tlsParams != null) { + ref.setTlsServerParameters(tlsParams); + } + portMap.put(port, ref); + ref.finalizeConfig(); + } + return ref; + } + /** * This call is used to set the bus. It should only be called once. @@ -141,7 +160,7 @@ public class JettyHTTPServerEngineFactor if (engine.getPort() == FALLBACK_THREADING_PARAMS_KEY) { fallbackThreadingParameters = engine.getThreadingParameters(); } - portMap.put(engine.getPort(), engine); + portMap.putIfAbsent(engine.getPort(), engine); } } @@ -179,10 +198,7 @@ public class JettyHTTPServerEngineFactor } JettyHTTPServerEngine ref = retrieveJettyHTTPServerEngine(port); if (null == ref) { - ref = new JettyHTTPServerEngine(this, bus, host, port); - ref.setTlsServerParameters(tlsParams); - portMap.put(port, ref); - ref.finalizeConfig(); + ref = getOrCreate(this, host, port, tlsParams); } else { if (ref.getConnector() != null && ref.getConnector().isRunning()) { throw new IOException("can't set the TLS params on the opened connector"); @@ -229,12 +245,7 @@ public class JettyHTTPServerEngineFactor public synchronized JettyHTTPServerEngine createJettyHTTPServerEngine(String host, int port, String protocol) throws GeneralSecurityException, IOException { LOG.fine("Creating Jetty HTTP Server Engine for port " + port + "."); - JettyHTTPServerEngine ref = retrieveJettyHTTPServerEngine(port); - if (null == ref) { - ref = new JettyHTTPServerEngine(this, bus, host, port); - portMap.put(port, ref); - ref.finalizeConfig(); - } + JettyHTTPServerEngine ref = getOrCreate(this, host, port, null); // checking the protocol if (!protocol.equals(ref.getProtocol())) { throw new IOException("Protocol mismatch for port " + port + ": " Modified: cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java URL: http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java?rev=1152014&r1=1152013&r2=1152014&view=diff ============================================================================== --- cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java (original) +++ cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/spring/JettyHTTPServerEngineBeanDefinitionParser.java Thu Jul 28 21:55:45 2011 @@ -156,13 +156,15 @@ public class JettyHTTPServerEngineBeanDe String threadingRef; String tlsRef; + Bus bus; public SpringJettyHTTPServerEngine( - JettyHTTPServerEngineFactory fac, - Bus bus, + JettyHTTPServerEngineFactory fac, + Bus b, String host, int port) { - super(fac, bus, host, port); + super(fac, host, port); + bus = b; } public SpringJettyHTTPServerEngine() { @@ -171,7 +173,7 @@ public class JettyHTTPServerEngineBeanDe public void setApplicationContext(ApplicationContext ctx) throws BeansException { - if (getBus() == null) { + if (bus == null) { Bus bus = BusFactory.getThreadDefaultBus(); BusWiringBeanFactoryPostProcessor.updateBusReferencesInContext(bus, ctx); setBus(bus); @@ -190,7 +192,9 @@ public class JettyHTTPServerEngineBeanDe throws GeneralSecurityException, IOException { if (tlsRef != null || threadingRef != null) { - retrieveEngineFactory(); + if (bus != null) { + setBus(bus); + } if (threadingRef != null) { setThreadingParameters(factory.getThreadingParametersMap().get(threadingRef)); }