cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [2/4] git commit: Change how maxIdle and reuseAddress is handled to make Jetty8/9 easier
Date Tue, 05 Aug 2014 17:53:41 GMT
Change how maxIdle and reuseAddress is handled to make Jetty8/9 easier


Project: http://git-wip-us.apache.org/repos/asf/cxf/repo
Commit: http://git-wip-us.apache.org/repos/asf/cxf/commit/13dfe0f9
Tree: http://git-wip-us.apache.org/repos/asf/cxf/tree/13dfe0f9
Diff: http://git-wip-us.apache.org/repos/asf/cxf/diff/13dfe0f9

Branch: refs/heads/master
Commit: 13dfe0f9fcaa0aee4c603072436d85861a0ab734
Parents: b67537d
Author: Daniel Kulp <dkulp@apache.org>
Authored: Tue Aug 5 12:31:01 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Tue Aug 5 12:31:01 2014 -0400

----------------------------------------------------------------------
 .../http_jetty/JettyConnectorFactory.java       | 10 ++-----
 .../http_jetty/JettyHTTPServerEngine.java       | 28 +++++++-------------
 .../https_jetty/JettySslConnectorFactory.java   | 24 +++++------------
 3 files changed, 17 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/13dfe0f9/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyConnectorFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyConnectorFactory.java
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyConnectorFactory.java
index 4020902..c5273b3 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyConnectorFactory.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyConnectorFactory.java
@@ -28,16 +28,10 @@ public interface JettyConnectorFactory {
 
     /**
      * Create a Listener.
-     * 
-     * @param port the listen port
-     */
-    AbstractConnector createConnector(int port);
-
-    /**
-     * Create a Listener.
+     * @param jettyHTTPServerEngine 
      * 
      * @param host the host to bind to.  IP address or hostname is allowed. null to bind
to all hosts.
      * @param port the listen port
      */
-    AbstractConnector createConnector(String host, int port);
+    AbstractConnector createConnector(JettyHTTPServerEngine jettyHTTPServerEngine, String
host, int port);
 }

http://git-wip-us.apache.org/repos/asf/cxf/blob/13dfe0f9/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
index c89209a..03540a5 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
@@ -334,7 +334,7 @@ public class JettyHTTPServerEngine
             }
             
             if (connector == null) {
-                connector = connectorFactory.createConnector(getHost(), getPort());
+                connector = connectorFactory.createConnector(this, getHost(), getPort());
                 if (LOG.isLoggable(Level.FINER)) {
                     logConnector(connector);
                 }
@@ -408,7 +408,6 @@ public class JettyHTTPServerEngine
             }
 
             try {                
-                setReuseAddress(connector);
                 setupThreadPool();
                 server.start();
             } catch (Exception e) {
@@ -540,14 +539,6 @@ public class JettyHTTPServerEngine
         return pool;
     }
     
-    private void setReuseAddress(Connector conn) throws IOException {
-        if (conn instanceof AbstractConnector) {
-            ((AbstractConnector)conn).setReuseAddress(isReuseAddress());
-        } else {
-            LOG.log(Level.INFO, "UNKNOWN_CONNECTOR_MSG", new Object[] {conn});
-        }
-    }
-
     /**
      * Remove a previously registered servant.
      * 
@@ -674,10 +665,7 @@ public class JettyHTTPServerEngine
      */
     protected JettyConnectorFactory getHTTPConnectorFactory() {
         return new JettyConnectorFactory() {
-            public AbstractConnector createConnector(int porto) {
-                return createConnector(null, porto);
-            }
-            public AbstractConnector createConnector(String hosto, int porto) {
+            public AbstractConnector createConnector(JettyHTTPServerEngine engine, String
hosto, int porto) {
                 /*
                 HttpConfiguration httpConfig = new HttpConfiguration();
                 httpConfig.setSendServerVersion(getSendServerVersion());
@@ -685,9 +673,10 @@ public class JettyHTTPServerEngine
                 ServerConnector httpConnector = new ServerConnector(server, httpFactory);
                 httpConnector.setPort(porto);
                 httpConnector.setHost(hosto);
-                if (getMaxIdleTime() > 0) {
-                    httpConnector.setIdleTimeout(getMaxIdleTime());
+                if (engine.getMaxIdleTime() > 0) {
+                    httpConnector.setIdleTimeout(engine.getMaxIdleTime());
                 }
+                httpConnector.setReuseAddress(engine.isReuseAddress());
                 return httpConnector;
                 */
                 
@@ -703,9 +692,10 @@ public class JettyHTTPServerEngine
                     result.setHost(hosto);
                 }
                 result.setPort(porto);
-                if (getMaxIdleTime() > 0) {
-                    result.setMaxIdleTime(getMaxIdleTime());
+                if (engine.getMaxIdleTime() > 0) {
+                    result.setMaxIdleTime(engine.getMaxIdleTime());
                 }
+                result.setReuseAddress(engine.isReuseAddress());
                 return result;
             }
         };
@@ -717,7 +707,7 @@ public class JettyHTTPServerEngine
     protected JettyConnectorFactory getHTTPSConnectorFactory(
             TLSServerParameters tlsParams
     ) {
-        return new JettySslConnectorFactory(tlsParams, getMaxIdleTime());
+        return new JettySslConnectorFactory(tlsParams);
     }
     
     /**

http://git-wip-us.apache.org/repos/asf/cxf/blob/13dfe0f9/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
index 2b6c5d2..da1fbc5 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/https_jetty/JettySslConnectorFactory.java
@@ -21,6 +21,7 @@ package org.apache.cxf.transport.https_jetty;
 
 import org.apache.cxf.configuration.jsse.TLSServerParameters;
 import org.apache.cxf.transport.http_jetty.JettyConnectorFactory;
+import org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine;
 import org.eclipse.jetty.server.AbstractConnector;
 
 /**
@@ -29,25 +30,11 @@ import org.eclipse.jetty.server.AbstractConnector;
  */
 public final class JettySslConnectorFactory implements JettyConnectorFactory {
     
-    TLSServerParameters tlsServerParameters;
-    int maxIdleTime;
+    final TLSServerParameters tlsServerParameters;
     
     public JettySslConnectorFactory(TLSServerParameters params) {
         tlsServerParameters = params;
     }
-    
-    public JettySslConnectorFactory(TLSServerParameters params, int maxIdle) {
-        this(params);
-        this.maxIdleTime = maxIdle;
-    }
-    /**
-     * Create a Listener.
-     * 
-     * @param port the listen port
-     */
-    public AbstractConnector createConnector(int port) {
-        return createConnector(null, port);
-    }
 
     /**
      * Create a Listener.
@@ -55,7 +42,7 @@ public final class JettySslConnectorFactory implements JettyConnectorFactory
{
      * @param host the host to bind to.  IP address or hostname is allowed. null to bind
to all hosts.
      * @param port the listen port
      */
-    public AbstractConnector createConnector(String host, int port) {
+    public AbstractConnector createConnector(JettyHTTPServerEngine engine, String host, int
port) {
         assert tlsServerParameters != null;
         
         CXFJettySslSocketConnector secureConnector = 
@@ -64,9 +51,10 @@ public final class JettySslConnectorFactory implements JettyConnectorFactory
{
             secureConnector.setHost(host);
         }
         secureConnector.setPort(port);
-        if (maxIdleTime > 0) {
-            secureConnector.setMaxIdleTime(maxIdleTime);
+        if (engine.getMaxIdleTime() > 0) {
+            secureConnector.setMaxIdleTime(engine.getMaxIdleTime());
         }
+        secureConnector.setReuseAddress(engine.isReuseAddress());
         decorateCXFJettySslSocketConnector(secureConnector);
         return secureConnector;
     }


Mime
View raw message