camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject camel git commit: The "server side" parts of jetty now work with Jetty 8 or 9. Lots to do for the client.
Date Wed, 19 Nov 2014 19:36:06 GMT
Repository: camel
Updated Branches:
  refs/heads/master e6f9f02fa -> e7b19da93


The "server side" parts of jetty now work with Jetty 8 or 9.  Lots to do for the client.


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

Branch: refs/heads/master
Commit: e7b19da93241dc24ebd0c7a885b0b115e71e071b
Parents: e6f9f02
Author: Daniel Kulp <dkulp@apache.org>
Authored: Wed Nov 19 14:26:36 2014 -0500
Committer: Daniel Kulp <dkulp@apache.org>
Committed: Wed Nov 19 14:35:54 2014 -0500

----------------------------------------------------------------------
 .../camel/component/jetty/CamelHttpClient.java  | 22 ++++++++++++++++++++
 .../component/jetty/JettyHttpComponent.java     | 21 ++++++++++---------
 2 files changed, 33 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e7b19da9/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.java
b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.java
index 664b4df..ac125c9 100644
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.java
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/CamelHttpClient.java
@@ -16,12 +16,15 @@
  */
 package org.apache.camel.component.jetty;
 
+import java.util.concurrent.Executor;
+
 import javax.net.ssl.SSLContext;
 
 import org.apache.camel.util.ObjectHelper;
 import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.eclipse.jetty.util.thread.QueuedThreadPool;
+import org.eclipse.jetty.util.thread.ThreadPool;
 
 public class CamelHttpClient extends HttpClient {
     
@@ -29,10 +32,12 @@ public class CamelHttpClient extends HttpClient {
     
     public CamelHttpClient() {
         super();
+        setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
     }
     
     public CamelHttpClient(SslContextFactory sslContextFactory) {
         super(sslContextFactory);
+        setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
     }
     
     @Deprecated
@@ -63,6 +68,22 @@ public class CamelHttpClient extends HttpClient {
         super.doStart();
     }
 
+    void setThreadPoolOrExecutor(Executor pool) {
+        try {
+            getClass().getMethod("setExecutor", Executor.class).invoke(this, pool);
+        } catch (Exception ex) {
+            try {
+                getClass().getMethod("setThreadPool", ThreadPool.class).invoke(this, pool);
+            } catch (Exception ex2) {
+                throw new RuntimeException(ex);
+            }
+        }
+    }
+    
+    public void setProxy(String host, int port) {
+        setProxy(new org.eclipse.jetty.client.Address(host, port));        
+    }
+    
     public boolean isSupportRedirect() {
         return supportRedirect;
     }
@@ -70,4 +91,5 @@ public class CamelHttpClient extends HttpClient {
     public void setSupportRedirect(boolean supportRedirect) {
         this.supportRedirect = supportRedirect;
     }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e7b19da9/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
index 597f2f8..edadd20 100644
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpComponent.java
@@ -705,18 +705,21 @@ public class JettyHttpComponent extends HttpComponent implements RestConsumerFac
                                                                              endpoint.isSendDateHeader());
             
             
-            
             if (result != null && requestBufferSize != null) {
-                result.setRequestBufferSize(requestBufferSize);
+                result.getClass().getMethod("setRequestBufferSize", Integer.TYPE)
+                    .invoke(result, requestBufferSize);
             }
             if (result != null && requestHeaderSize != null) {
-                result.setRequestHeaderSize(requestHeaderSize);
+                result.getClass().getMethod("setRequestHeaderSize", Integer.TYPE)
+                    .invoke(result, requestHeaderSize);
             }
             if (result != null && responseBufferSize != null) {
-                result.setResponseBufferSize(responseBufferSize);
+                result.getClass().getMethod("setResponseBufferSize", Integer.TYPE)
+                    .invoke(result, responseBufferSize);
             }
             if (result != null && responseHeaderSize != null) {
-                result.setResponseBufferSize(responseHeaderSize);
+                result.getClass().getMethod("setResponseBufferSize", Integer.TYPE)
+                    .invoke(result, responseHeaderSize);
             }
 
         } catch (RuntimeException rex) {
@@ -777,7 +780,6 @@ public class JettyHttpComponent extends HttpComponent implements RestConsumerFac
         } else {
             httpClient = new CamelHttpClient();
         }
-        httpClient.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL);
         
         CamelContext context = endpoint.getCamelContext();
 
@@ -787,14 +789,14 @@ public class JettyHttpComponent extends HttpComponent implements RestConsumerFac
             String host = context.getProperty("http.proxyHost");
             int port = Integer.parseInt(context.getProperty("http.proxyPort"));
             LOG.debug("CamelContext properties http.proxyHost and http.proxyPort detected.
Using http proxy host: {} port: {}", host, port);
-            httpClient.setProxy(new org.eclipse.jetty.client.Address(host, port));
+            httpClient.setProxy(host, port);
         }
 
         if (ObjectHelper.isNotEmpty(endpoint.getProxyHost()) && endpoint.getProxyPort()
> 0) {
             String host = endpoint.getProxyHost();
             int port = endpoint.getProxyPort();
             LOG.debug("proxyHost and proxyPort options detected. Using http proxy host: {}
port: {}", host, port);
-            httpClient.setProxy(new org.eclipse.jetty.client.Address(host, port));
+            httpClient.setProxy(host, port);
         }
         
         // must have both min and max
@@ -813,8 +815,7 @@ public class JettyHttpComponent extends HttpComponent implements RestConsumerFac
             qtp.setDaemon(true);
             // let the thread names indicate they are from the client
             qtp.setName("CamelJettyClient(" + ObjectHelper.getIdentityHashCode(httpClient)
+ ")");
-            httpClient.setThreadPool(qtp);
-            //httpClient.setExecutor(qtp);
+            httpClient.setThreadPoolOrExecutor(qtp);
         }
         
         if (LOG.isDebugEnabled()) {


Mime
View raw message