cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [1/4] git commit: Start the process of issolating Jetty 8 and 9 differences.
Date Tue, 05 Aug 2014 17:53:40 GMT
Repository: cxf
Updated Branches:
  refs/heads/master bea22d764 -> 88adfaf2a


Start the process of issolating Jetty 8 and 9 differences.


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

Branch: refs/heads/master
Commit: b67537dbace0896073b55b375b8ccdc4cce83365
Parents: bea22d7
Author: Daniel Kulp <dkulp@apache.org>
Authored: Tue Aug 5 12:21:13 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Tue Aug 5 12:21:39 2014 -0400

----------------------------------------------------------------------
 parent/pom.xml                                  |   6 +-
 rt/transports/http-jetty/pom.xml                |   5 +
 .../http_jetty/JettyHTTPServerEngine.java       | 111 ++++++++++++-------
 3 files changed, 80 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/b67537db/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index e010fbf..833b409 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -114,8 +114,10 @@
         <cxf.joda.time.version>2.2</cxf.joda.time.version>
         <cxf.jdom.version>1.0</cxf.jdom.version>
         <cxf.jettison.version>1.3.5</cxf.jettison.version>
-        <cxf.jetty.version>8.1.15.v20140411</cxf.jetty.version>
-        <cxf.jetty.osgi.version>[7.6,8.2)</cxf.jetty.osgi.version>
+        <cxf.jetty8.version>8.1.15.v20140411</cxf.jetty8.version>
+        <cxf.jetty9.version>9.2.2.v20140723</cxf.jetty9.version>
+        <cxf.jetty.version>${cxf.jetty8.version}</cxf.jetty.version>
+        <cxf.jetty.osgi.version>[8.1,10)</cxf.jetty.osgi.version>
         <cxf.jibx.version>1.2.5</cxf.jibx.version>
         <cxf.junit.version>4.11</cxf.junit.version>
         <cxf.maven.core.version>2.2.1</cxf.maven.core.version>

http://git-wip-us.apache.org/repos/asf/cxf/blob/b67537db/rt/transports/http-jetty/pom.xml
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/pom.xml b/rt/transports/http-jetty/pom.xml
index f659c1e..0e3d1b1 100644
--- a/rt/transports/http-jetty/pom.xml
+++ b/rt/transports/http-jetty/pom.xml
@@ -99,6 +99,11 @@
         </dependency>
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-continuation</artifactId>
+            <version>${cxf.jetty.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-jmx</artifactId>
             <version>${cxf.jetty.version}</version>
             <optional>true</optional>

http://git-wip-us.apache.org/repos/asf/cxf/blob/b67537db/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 c490c7c..c89209a 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
@@ -19,6 +19,7 @@
 
 package org.apache.cxf.transport.http_jetty;
 
+import java.io.Closeable;
 import java.io.IOException;
 import java.net.URL;
 import java.security.GeneralSecurityException;
@@ -329,20 +330,15 @@ public class JettyHTTPServerEngine
             server.setSendServerVersion(getSendServerVersion());
             
             if (mBeanContainer != null) {
-                server.getContainer().addEventListener(mBeanContainer);
+                getContainer(server).addEventListener(mBeanContainer);
             }
             
             if (connector == null) {
                 connector = connectorFactory.createConnector(getHost(), getPort());
                 if (LOG.isLoggable(Level.FINER)) {
-                    LOG.finer("connector.host: " 
-                              + connector.getHost() == null 
-                                ? "null" 
-                                : "\"" + connector.getHost() + "\"");
-                    LOG.finer("connector.port: " + connector.getPort());
+                    logConnector(connector);
                 }
             } 
-
             server.addConnector(connector);
             /*
              * The server may have no handler, it might have a collection handler,
@@ -477,20 +473,40 @@ public class JettyHTTPServerEngine
         ++servantCount;
     }
     
+    private static Container getContainer(Object server) {
+        if (server instanceof Container) {
+            return (Container)server;
+        }
+        try {
+            return (Container)server.getClass().getMethod("getContainer").invoke(server);
+        } catch (RuntimeException t) {
+            throw t;
+        } catch (Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
+
+    private static void logConnector(Connector connector) {
+        try {
+            String h = (String)connector.getClass().getMethod("getHost").invoke(connector);
+            int port = (Integer)connector.getClass().getMethod("getPort").invoke(connector);
+            LOG.finer("connector.host: " 
+                + h == null 
+                  ? "null" 
+                  : "\"" + h + "\"");
+            LOG.finer("connector.port: " + port);
+        } catch (Throwable t) {
+            //ignore
+        }
+    }
+
     protected void setupThreadPool() {
-        AbstractConnector aconn = (AbstractConnector) connector;
         if (isSetThreadingParameters()) {
-            ThreadPool pool = aconn.getThreadPool();
-            if (pool == null) {
-                pool = aconn.getServer().getThreadPool();
-            }
-            if (pool == null) {
-                pool = new QueuedThreadPool();
-                aconn.getServer().setThreadPool(pool);
-                aconn.setThreadPool(pool);
-            }
+            
+            QueuedThreadPool pl = getThreadPool();
             //threads for the acceptors and selectors are taken from 
             //the pool so we need to have room for those
+            AbstractConnector aconn = (AbstractConnector) connector;
             int acc = aconn.getAcceptors() * 2;
             if (getThreadingParameters().isSetMaxThreads()
                 && getThreadingParameters().getMaxThreads() <= acc) {
@@ -500,32 +516,30 @@ public class JettyHTTPServerEngine
                                             getThreadingParameters().getMaxThreads(),
                                             acc));
             }
-            if (pool instanceof QueuedThreadPool) {
-                QueuedThreadPool pl = (QueuedThreadPool)pool;
-                if (getThreadingParameters().isSetMinThreads()) {
-                    pl.setMinThreads(getThreadingParameters().getMinThreads());
-                }
-                if (getThreadingParameters().isSetMaxThreads()) {
-                    pl.setMaxThreads(getThreadingParameters().getMaxThreads());
-                }
-            } else {
-                try {
-                    if (getThreadingParameters().isSetMinThreads()) {
-                        pool.getClass().getMethod("setMinThreads", Integer.TYPE)
-                            .invoke(pool, getThreadingParameters().getMinThreads());
-                    }
-                    if (getThreadingParameters().isSetMaxThreads()) {
-                        pool.getClass().getMethod("setMaxThreads", Integer.TYPE)
-                            .invoke(pool, getThreadingParameters().getMaxThreads());
-                    }
-                } catch (Throwable t) {
-                    //ignore - this won't happen for Jetty 7.1 - 7.2 and 7.3 and newer 
-                    //will be instanceof QueuedThreadPool above
-                }
+            if (getThreadingParameters().isSetMinThreads()) {
+                pl.setMinThreads(getThreadingParameters().getMinThreads());
+            }
+            if (getThreadingParameters().isSetMaxThreads()) {
+                pl.setMaxThreads(getThreadingParameters().getMaxThreads());
             }
         }
     }
     
+    private QueuedThreadPool getThreadPool() {
+        QueuedThreadPool pool = (QueuedThreadPool)server.getThreadPool();
+        if (pool == null) {
+            pool = new QueuedThreadPool();
+            try {
+                server.getClass().getMethod("setThreadPool", ThreadPool.class).invoke(server,
pool);
+            } catch (RuntimeException t) {
+                throw t;
+            } catch (Throwable t) {
+                throw new RuntimeException(t);
+            }
+        }
+        return pool;
+    }
+    
     private void setReuseAddress(Connector conn) throws IOException {
         if (conn instanceof AbstractConnector) {
             ((AbstractConnector)conn).setReuseAddress(isReuseAddress());
@@ -664,6 +678,19 @@ public class JettyHTTPServerEngine
                 return createConnector(null, porto);
             }
             public AbstractConnector createConnector(String hosto, int porto) {
+                /*
+                HttpConfiguration httpConfig = new HttpConfiguration();
+                httpConfig.setSendServerVersion(getSendServerVersion());
+                HttpConnectionFactory httpFactory = new HttpConnectionFactory(httpConfig);
+                ServerConnector httpConnector = new ServerConnector(server, httpFactory);
+                httpConnector.setPort(porto);
+                httpConnector.setHost(hosto);
+                if (getMaxIdleTime() > 0) {
+                    httpConnector.setIdleTimeout(getMaxIdleTime());
+                }
+                return httpConnector;
+                */
+                
                 // now we just use the SelectChannelConnector as the default connector
                 SelectChannelConnector result = 
                     new SelectChannelConnector();
@@ -724,7 +751,11 @@ public class JettyHTTPServerEngine
         if (server != null) {
             try {
                 connector.stop();
-                connector.close();            
+                if (connector instanceof Closeable) {
+                    ((Closeable)connector).close();
+                } else {
+                    connector.getClass().getMethod("close").invoke(connector);
+                }
             } finally {         
                 server.stop();
                 server.destroy();


Mime
View raw message