cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject [3/6] git commit: Get jca tests passing with Jetty9
Date Thu, 07 Aug 2014 20:58:25 GMT
Get jca tests passing with Jetty9


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

Branch: refs/heads/master
Commit: a7b79ea692add4f9da0f1232e3bfb338099f4147
Parents: 8f96764
Author: Daniel Kulp <dkulp@apache.org>
Authored: Thu Aug 7 15:40:40 2014 -0400
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Thu Aug 7 15:40:40 2014 -0400

----------------------------------------------------------------------
 .../org/apache/cxf/jca/servant/EJBEndpoint.java |  7 +--
 .../http_jetty/JettyHTTPServerEngine.java       | 45 +++++++++++++++-----
 .../transport/http_jetty/Messages.properties    |  2 +-
 rt/transports/websocket/pom.xml                 | 28 ++++++++++++
 4 files changed, 65 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cxf/blob/a7b79ea6/integration/jca/src/main/java/org/apache/cxf/jca/servant/EJBEndpoint.java
----------------------------------------------------------------------
diff --git a/integration/jca/src/main/java/org/apache/cxf/jca/servant/EJBEndpoint.java b/integration/jca/src/main/java/org/apache/cxf/jca/servant/EJBEndpoint.java
index f2d06d6..01ea8f7 100644
--- a/integration/jca/src/main/java/org/apache/cxf/jca/servant/EJBEndpoint.java
+++ b/integration/jca/src/main/java/org/apache/cxf/jca/servant/EJBEndpoint.java
@@ -41,8 +41,6 @@ import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
 import org.apache.cxf.jca.cxf.WorkManagerThreadPool;
 import org.apache.cxf.transport.http_jetty.JettyHTTPServerEngine;
 import org.apache.cxf.transport.http_jetty.JettyHTTPServerEngineFactory;
-import org.eclipse.jetty.server.AbstractConnector;
-import org.eclipse.jetty.server.nio.SelectChannelConnector;
 
 
 public class EJBEndpoint {
@@ -110,10 +108,7 @@ public class EJBEndpoint {
             return;
         }
         JettyHTTPServerEngine engine = new JettyHTTPServerEngine();
-        AbstractConnector connector = new SelectChannelConnector();
-        connector.setPort(port);
-        connector.setThreadPool(new WorkManagerThreadPool(getWorkManager()));
-        engine.setConnector(connector);
+        engine.setThreadPool(new WorkManagerThreadPool(getWorkManager()));
         engine.setPort(port);
         
         List<JettyHTTPServerEngine> engineList = new ArrayList<JettyHTTPServerEngine>();

http://git-wip-us.apache.org/repos/asf/cxf/blob/a7b79ea6/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 853b7d4..2e6d841 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
@@ -107,6 +107,7 @@ public class JettyHTTPServerEngine
     private ContextHandlerCollection contexts;
     private Container.Listener mBeanContainer;
     private SessionManager sessionManager;
+    private ThreadPool threadPool;
     
     
     /**
@@ -144,6 +145,9 @@ public class JettyHTTPServerEngine
     public JettyHTTPServerEngine() {
         
     }
+    public void setThreadPool(ThreadPool p) {
+        threadPool = p;
+    }
      
     public void setPort(int p) {
         port = p;
@@ -316,6 +320,25 @@ public class JettyHTTPServerEngine
         
     }
     
+    private Server createServer() {
+        Server s = null;
+        if (threadPool != null) {
+            try {
+                if (!Server.getVersion().startsWith("8")) {
+                    s = Server.class.getConstructor(ThreadPool.class).newInstance(threadPool);
+                } else {
+                    s = new Server();
+                    Server.class.getMethod("setThreadPool", ThreadPool.class).invoke(s, threadPool);
+                }
+            } catch (Exception e) {
+                //ignore
+            }
+        }
+        if (s == null) {
+            s = new Server();
+        }
+        return s;
+    }
     
     /**
      * Register a servant.
@@ -331,11 +354,11 @@ public class JettyHTTPServerEngine
         SecurityHandler securityHandler = null;
         if (server == null) {
             DefaultHandler defaultHandler = null;
-            // create a new jetty server instance if there is no server there           

-            server = new Server();
-
+            // create a new jetty server instance if there is no server there
+            server = createServer();
             addServerMBean();
-                                    
+            setupThreadPool();
+                    
             if (connector == null) {
                 connector = createConnector(getHost(), getPort());
                 if (LOG.isLoggable(Level.FINER)) {
@@ -411,7 +434,6 @@ public class JettyHTTPServerEngine
             }
 
             try {                
-                setupThreadPool();
                 server.start();
             } catch (Exception e) {
                 LOG.log(Level.SEVERE, "START_UP_SERVER_FAILED_MSG", new Object[] {e.getMessage(),
port});
@@ -708,7 +730,7 @@ public class JettyHTTPServerEngine
     protected void setupThreadPool() {
         if (isSetThreadingParameters()) {
             
-            QueuedThreadPool pl = getThreadPool();
+            ThreadPool 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;
@@ -721,17 +743,20 @@ public class JettyHTTPServerEngine
                                             getThreadingParameters().getMaxThreads(),
                                             acc));
             }
+            if (!(pl instanceof QueuedThreadPool)) {
+                throw new Fault(new Message("NOT_A_QUEUED_THREAD_POOL", LOG, pl.getClass()));
+            }
             if (getThreadingParameters().isSetMinThreads()) {
-                pl.setMinThreads(getThreadingParameters().getMinThreads());
+                ((QueuedThreadPool)pl).setMinThreads(getThreadingParameters().getMinThreads());
             }
             if (getThreadingParameters().isSetMaxThreads()) {
-                pl.setMaxThreads(getThreadingParameters().getMaxThreads());
+                ((QueuedThreadPool)pl).setMaxThreads(getThreadingParameters().getMaxThreads());
             }
         }
     }
     
-    private QueuedThreadPool getThreadPool() {
-        QueuedThreadPool pool = (QueuedThreadPool)server.getThreadPool();
+    private ThreadPool getThreadPool() {
+        ThreadPool pool = (ThreadPool)server.getThreadPool();
         if (pool == null) {
             pool = new QueuedThreadPool();
             try {

http://git-wip-us.apache.org/repos/asf/cxf/blob/a7b79ea6/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties
----------------------------------------------------------------------
diff --git a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties
b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties
index 3e864f3..8c0f051 100644
--- a/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties
+++ b/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties
@@ -29,7 +29,7 @@ UNKNOWN_CONNECTOR_MSG = Unknown connector type {0}, can''t set the socket
reuseA
 INVALID_ENCODING_MSG = Invalid character set {0} in request.
 FALLBACK_THREADING_PARAMETERS_MSG = No explicitly configured threading parameters for port
{0}, using fallback values min:{1} max:{2}
 NOT_ENOUGH_THREADS = Not enough threads configured for port {0}.  Need at least {1} ({3}
for Jetty selectors and set managers) but only {2} configured.
-
+NOT_A_QUEUED_THREAD_POOL = {0} is not an instanceof QueuedThreadPool.  Cannot set threading
parameters.
 
 SSL_CONTEXT_INIT_FAILURE = Problem initializing ssl for the outbound request, exception reported
from security provider is : {0}
 UNKNOWN_SSL_CLIENT_POLICY_DATA = Unknown SSLClientPolicy property : {0}

http://git-wip-us.apache.org/repos/asf/cxf/blob/a7b79ea6/rt/transports/websocket/pom.xml
----------------------------------------------------------------------
diff --git a/rt/transports/websocket/pom.xml b/rt/transports/websocket/pom.xml
index 285dc27..7ef92bc 100644
--- a/rt/transports/websocket/pom.xml
+++ b/rt/transports/websocket/pom.xml
@@ -110,6 +110,7 @@
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-server</artifactId>
+            <version>${cxf.jetty8.version}</version>
             <exclusions>
                 <exclusion>
                     <groupId>javax.servlet</groupId>
@@ -124,14 +125,41 @@
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-security</artifactId>
+            <version>${cxf.jetty8.version}</version>
         </dependency>
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-servlet</artifactId>
+            <version>${cxf.jetty8.version}</version>
         </dependency>
         <dependency>
             <groupId>org.eclipse.jetty</groupId>
             <artifactId>jetty-jmx</artifactId>
+            <version>${cxf.jetty8.version}</version>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-util</artifactId>
+            <version>${cxf.jetty8.version}</version>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-io</artifactId>
+            <version>${cxf.jetty8.version}</version>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-http</artifactId>
+            <version>${cxf.jetty8.version}</version>
+            <optional>true</optional>
+        </dependency>
+        <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>jetty-continuation</artifactId>
+            <version>${cxf.jetty8.version}</version>
             <optional>true</optional>
         </dependency>
         


Mime
View raw message