cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
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 GMT
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<Integer, JettyHTTPServerEngine> portMap =
-        new HashMap<Integer, JettyHTTPServerEngine>();
+    private static ConcurrentHashMap<Integer, JettyHTTPServerEngine> portMap =
+        new ConcurrentHashMap<Integer, JettyHTTPServerEngine>();
+    
+    
    
     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));
                 }



Mime
View raw message