camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cschnei...@apache.org
Subject [2/2] camel git commit: Make sure tests work for jetty 8
Date Tue, 13 Jan 2015 13:41:54 GMT
Make sure tests work for jetty 8


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

Branch: refs/heads/temp-jetty9
Commit: 85c890f73263d628007afa80d658dec4d44a3b0a
Parents: 95fc3e9
Author: Christian Schneider <chris@die-schneider.net>
Authored: Tue Jan 13 14:41:39 2015 +0100
Committer: Christian Schneider <chris@die-schneider.net>
Committed: Tue Jan 13 14:41:39 2015 +0100

----------------------------------------------------------------------
 .../component/jetty/AttachmentHttpBinding.java  |  75 -----
 .../component/jetty/JettyHttpComponent.java     | 194 +-----------
 .../component/jetty/JettyHttpEndpoint.java      |   5 -
 .../component/jetty/JettyHttpProducer.java      |  18 +-
 .../component/jetty8/CamelHttpClient8.java      |  16 +
 .../component/jetty8/CamelRedirectListener.java |  52 ++++
 .../component/jetty8/JettyContentExchange8.java | 287 +++++++++++++++++
 .../component/jetty8/JettyHttpComponent8.java   |  96 ++++++
 .../component/jetty9/CamelHttpClient9.java      |  42 ---
 .../component/jetty9/JettyContentExchange9.java | 304 -------------------
 .../component/jetty9/JettyHttpComponent9.java   |  29 --
 .../component/jetty9/AttachmentHttpBinding.java |  75 +++++
 .../component/jetty9/CamelHttpClient9.java      |  42 +++
 .../component/jetty9/JettyContentExchange9.java | 304 +++++++++++++++++++
 .../component/jetty9/JettyHttpComponent9.java   | 140 +++++++++
 .../component/jetty9/JettyHttpEndpoint9.java    |  18 ++
 .../services/org/apache/camel/component/jetty   |   2 +-
 .../camel/component/jetty/BaseJettyTest.java    |   1 +
 .../component/jetty/ExplicitHttpsRouteTest.java |  24 +-
 ...licitHttpsSslContextParametersRouteTest.java |  22 +-
 .../jetty/HttpProducerSendEmptyHeaderTest.java  |   2 +-
 .../component/jetty/HttpsRouteAliasTest.java    |   1 +
 ...ttpsRouteWithSslConnectorPropertiesTest.java |   2 +
 .../jetty/JettyHttpClientOptionsTest.java       |  19 +-
 .../JettyComponentSpringConfiguredTest.xml      |   2 +-
 .../camel/component/jetty/jetty-https.xml       |   2 +-
 26 files changed, 1098 insertions(+), 676 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/AttachmentHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/AttachmentHttpBinding.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/AttachmentHttpBinding.java
deleted file mode 100644
index 98afd26..0000000
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/AttachmentHttpBinding.java
+++ /dev/null
@@ -1,75 +0,0 @@
-package org.apache.camel.component.jetty;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Collection;
-
-import javax.activation.DataHandler;
-import javax.activation.DataSource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.Part;
-
-import org.apache.camel.component.http.DefaultHttpBinding;
-import org.apache.camel.component.http.HttpEndpoint;
-import org.apache.camel.component.http.HttpMessage;
-import org.eclipse.jetty.util.MultiPartInputStreamParser;
-
-final class AttachmentHttpBinding extends DefaultHttpBinding {
-    AttachmentHttpBinding(HttpEndpoint endpoint) {
-        super(endpoint);
-    }
-
-    @Override
-    protected void populateAttachments(HttpServletRequest request, HttpMessage message) {
-        Object object = request.getAttribute("org.eclipse.jetty.servlet.MultiPartFile.multiPartInputStream");
-        if (object instanceof MultiPartInputStreamParser) {
-                MultiPartInputStreamParser parser = (MultiPartInputStreamParser)object;
-                Collection<Part> parts;
-                try {
-                    parts = parser.getParts();
-                    for (Part part : parts) {
-                        String contentType = part.getContentType();
-                        if (!contentType.startsWith("application/octet-stream")) {
-                            continue;
-                        }
-                       
-                        DataSource ds = new PartDataSource(part);
-                        message.addAttachment(part.getName(), new DataHandler(ds));
-                    }
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-                
-                
-        }
-    }
-    
-    final class PartDataSource implements DataSource {
-        private final Part part;
-
-        PartDataSource(Part part) {
-            this.part = part;
-        }
-
-        @Override
-        public OutputStream getOutputStream() throws IOException {
-            return null;
-        }
-
-        @Override
-        public String getName() {
-            return part.getName();
-        }
-
-        @Override
-        public InputStream getInputStream() throws IOException {
-            return part.getInputStream();
-        }
-
-        @Override
-        public String getContentType() {
-            return part.getContentType();
-        }
-    }
-}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/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 1595fbe..c2b6119 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
@@ -22,6 +22,7 @@ import java.io.Writer;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.security.GeneralSecurityException;
 import java.util.ArrayList;
 import java.util.HashMap;
@@ -62,16 +63,11 @@ import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.http.HttpStatus;
 import org.eclipse.jetty.jmx.MBeanContainer;
 import org.eclipse.jetty.server.AbstractConnector;
-import org.eclipse.jetty.server.ConnectionFactory;
 import org.eclipse.jetty.server.Connector;
 import org.eclipse.jetty.server.Handler;
-import org.eclipse.jetty.server.HttpConfiguration;
-import org.eclipse.jetty.server.HttpConnectionFactory;
 import org.eclipse.jetty.server.Request;
 import org.eclipse.jetty.server.Response;
 import org.eclipse.jetty.server.Server;
-import org.eclipse.jetty.server.ServerConnector;
-import org.eclipse.jetty.server.SslConnectionFactory;
 import org.eclipse.jetty.server.handler.ContextHandlerCollection;
 import org.eclipse.jetty.server.handler.ErrorHandler;
 import org.eclipse.jetty.server.handler.HandlerCollection;
@@ -95,7 +91,6 @@ import org.slf4j.LoggerFactory;
  *
  * @version 
  */
-@SuppressWarnings("deprecation")
 public abstract class JettyHttpComponent extends HttpComponent implements RestConsumerFactory {
     public static final String TMP_DIR = "CamelJettyTempDir";
     
@@ -109,7 +104,7 @@ public abstract class JettyHttpComponent extends HttpComponent implements RestCo
     protected String sslKeyPassword;
     protected String sslPassword;
     protected String sslKeystore;
-    protected Map<Integer, SslContextFactory> sslSocketConnectors;
+    protected Map<Integer, Connector> sslSocketConnectors;
     protected Map<Integer, Connector> socketConnectors;
     protected Map<String, Object> sslSocketConnectorProperties;
     protected Map<String, Object> socketConnectorProperties;
@@ -202,7 +197,7 @@ public abstract class JettyHttpComponent extends HttpComponent implements RestCo
         // restructure uri to be based on the parameters left as we dont want to include the Camel internal options
         URI httpUri = URISupport.createRemainingURI(addressUri, parameters);
         // create endpoint after all known parameters have been extracted from parameters
-        JettyHttpEndpoint endpoint = new JettyHttpEndpoint(this, endpointUri.toString(), httpUri);
+        JettyHttpEndpoint endpoint = createEndpoint(endpointUri, httpUri);
         
         
         if (headerFilterStrategy != null) {
@@ -307,6 +302,10 @@ public abstract class JettyHttpComponent extends HttpComponent implements RestCo
         return endpoint;
     }
 
+    protected JettyHttpEndpoint createEndpoint(URI endpointUri, URI httpUri) throws URISyntaxException {
+        return new JettyHttpEndpoint(this, endpointUri.toString(), httpUri);
+    }
+
     /**
      * Connects the URL specified on the endpoint to the specified processor.
      */
@@ -535,15 +534,7 @@ public abstract class JettyHttpComponent extends HttpComponent implements RestCo
     protected Connector getSslSocketConnector(Server server, JettyHttpEndpoint endpoint) {
         Connector answer = null;
         if (sslSocketConnectors != null) {
-            SslContextFactory con = sslSocketConnectors.get(endpoint.getPort());
-            if (con != null) {
-                SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(con, null);
-                @SuppressWarnings("resource")
-                ServerConnector sc = new ServerConnector(server, sslConnectionFactory);
-                sc.setPort(endpoint.getPort());
-                sc.setHost(endpoint.getHttpUri().getHost());
-                answer = sc;
-            }
+            answer = sslSocketConnectors.get(endpoint.getPort());
         }
         if (answer == null) {
             answer = createConnector(server, endpoint);
@@ -552,8 +543,7 @@ public abstract class JettyHttpComponent extends HttpComponent implements RestCo
     }
         
     protected Connector createConnector(Server server, JettyHttpEndpoint endpoint) {
-        String hosto = endpoint.getHttpUri().getHost();
-        int porto = endpoint.getPort();
+
         
         // now we just use the SelectChannelConnector as the default connector
         SslContextFactory sslcf = null;
@@ -594,166 +584,10 @@ public abstract class JettyHttpComponent extends HttpComponent implements RestCo
             }
         }
 
-        AbstractConnector result = null;
-        if (!Server.getVersion().startsWith("8")) {
-            result = createConnectorJetty9(server, endpoint, sslcf, hosto, porto);
-        } else {
-            result = createConnectorJetty8(server, endpoint, sslcf, hosto, porto);
-            try {
-                if (getSocketConnectorProperties() != null && !"https".equals(endpoint.getProtocol())) {
-                    // must copy the map otherwise it will be deleted
-                    Map<String, Object> properties = new HashMap<String, Object>(getSocketConnectorProperties());
-                    IntrospectionSupport.setProperties(result, properties);
-                    if (properties.size() > 0) {
-                        throw new IllegalArgumentException("There are " + properties.size()
-                            + " parameters that couldn't be set on the SocketConnector."
-                            + " Check the uri if the parameters are spelt correctly and that they are properties of the SelectChannelConnector."
-                            + " Unknown parameters=[" + properties + "]");
-                    }
-                } else if (getSslSocketConnectorProperties() != null && "https".equals(endpoint.getProtocol())) {
-                    // must copy the map otherwise it will be deleted
-                    Map<String, Object> properties = new HashMap<String, Object>(getSslSocketConnectorProperties());
-                    IntrospectionSupport.setProperties(result, properties);
-                    if (properties.size() > 0) {
-                        throw new IllegalArgumentException("There are " + properties.size()
-                            + " parameters that couldn't be set on the SocketConnector."
-                            + " Check the uri if the parameters are spelt correctly and that they are properties of the SelectChannelConnector."
-                            + " Unknown parameters=[" + properties + "]");
-                    }                
-                }
-            } catch (RuntimeException rex) {
-                throw rex;
-            } catch (Exception ex) {
-                throw new RuntimeException(ex);
-            }    
-        }        
-        return result;
+        return createConnectorJettyInternal(server, endpoint, sslcf);
     }
-    protected AbstractConnector createConnectorJetty9(Server server,
-                                                      JettyHttpEndpoint endpoint,
-                                                      SslContextFactory sslcf,
-                                                      String hosto, int porto) {
-        try {
-            HttpConfiguration httpConfig = new org.eclipse.jetty.server.HttpConfiguration();
-            httpConfig.setSendServerVersion(endpoint.isSendServerVersion());
-            httpConfig.setSendDateHeader(endpoint.isSendDateHeader());
-            httpConfig.setSendDateHeader(endpoint.isSendDateHeader());
-            
-            if (requestBufferSize != null) {
-                // Does not work
-                //httpConfig.setRequestBufferSize(requestBufferSize);
-            }
-            if (requestHeaderSize != null) {
-                httpConfig.setRequestHeaderSize(requestHeaderSize);
-            }
-            if (responseBufferSize != null) {
-                httpConfig.setOutputBufferSize(responseBufferSize);
-            }
-            if (responseHeaderSize != null) {
-                httpConfig.setResponseHeaderSize(responseHeaderSize);
-            }
-            
-            HttpConnectionFactory httpFactory = new org.eclipse.jetty.server.HttpConnectionFactory(httpConfig); 
-
-            ArrayList<ConnectionFactory> connectionFactories = new ArrayList<ConnectionFactory>();
-            ServerConnector result = new org.eclipse.jetty.server.ServerConnector(server);
-            if (sslcf != null) {
-                httpConfig.addCustomizer(new org.eclipse.jetty.server.SecureRequestCustomizer());
-                SslConnectionFactory scf = new org.eclipse.jetty.server.SslConnectionFactory(sslcf, "HTTP/1.1");
-                connectionFactories.add(scf);
-                result.setDefaultProtocol("SSL-HTTP/1.1");
-            }
-            connectionFactories.add(httpFactory);
-            result.setConnectionFactories(connectionFactories);
-            result.setPort(porto);
-            if (hosto != null) {
-                result.setHost(hosto);
-            }
-            /*
-            if (getSocketConnectorProperties() != null && !"https".equals(endpoint.getProtocol())) {
-                // must copy the map otherwise it will be deleted
-                Map<String, Object> properties = new HashMap<String, Object>(getSocketConnectorProperties());
-                IntrospectionSupport.setProperties(httpConfig, properties);
-                if (properties.size() > 0) {
-                    throw new IllegalArgumentException("There are " + properties.size()
-                        + " parameters that couldn't be set on the SocketConnector."
-                        + " Check the uri if the parameters are spelt correctly and that they are properties of the SelectChannelConnector."
-                        + " Unknown parameters=[" + properties + "]");
-                }
-            } else*/
-            if (getSslSocketConnectorProperties() != null && "https".equals(endpoint.getProtocol())) {
-                // must copy the map otherwise it will be deleted
-                Map<String, Object> properties = new HashMap<String, Object>(getSslSocketConnectorProperties());
-                IntrospectionSupport.setProperties(sslcf, properties);
-                if (properties.size() > 0) {
-                    throw new IllegalArgumentException("There are " + properties.size()
-                        + " parameters that couldn't be set on the SocketConnector."
-                        + " Check the uri if the parameters are spelt correctly and that they are properties of the SelectChannelConnector."
-                        + " Unknown parameters=[" + properties + "]");
-                }                
-            }
-            return result;
-        } catch (RuntimeException rex) {
-            throw rex;
-        } catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-    }
-    protected AbstractConnector createConnectorJetty8(Server server,
-                                                      JettyHttpEndpoint endpoint,
-                                                      SslContextFactory sslcf,
-                                                      String hosto, int porto) {
-        //Jetty 8
-        AbstractConnector result = null;
-        try {
-            if (sslcf == null && !"https".equals(endpoint.getProtocol())) { 
-                result = (AbstractConnector)ObjectHelper
-                    .loadClass("org.eclipse.jetty.server.nio.SelectChannelConnector",
-                               Server.class.getClassLoader()).newInstance();
-            } else if (sslcf == null) {
-                result = (AbstractConnector)ObjectHelper
-                    .loadClass("org.eclipse.jetty.server.ssl.SslSelectChannelConnector",
-                               Server.class.getClassLoader()).newInstance();
-            } else {
-                result = (AbstractConnector)ObjectHelper
-                    .loadClass("org.eclipse.jetty.server.ssl.SslSelectChannelConnector",
-                               Server.class.getClassLoader()).getConstructor(SslContextFactory.class)
-                               .newInstance(sslcf);
-            }
-            Server.class.getMethod("setSendServerVersion", Boolean.TYPE).invoke(server, 
-                                                                                endpoint.isSendServerVersion());
-            
-            Server.class.getMethod("setSendDateHeader", Boolean.TYPE).invoke(server, 
-                                                                             endpoint.isSendDateHeader());
-            
-            
-            if (result != null && requestBufferSize != null) {
-                result.getClass().getMethod("setRequestBufferSize", Integer.TYPE)
-                    .invoke(result, requestBufferSize);
-            }
-            if (result != null && requestHeaderSize != null) {
-                result.getClass().getMethod("setRequestHeaderSize", Integer.TYPE)
-                    .invoke(result, requestHeaderSize);
-            }
-            if (result != null && responseBufferSize != null) {
-                result.getClass().getMethod("setResponseBufferSize", Integer.TYPE)
-                    .invoke(result, responseBufferSize);
-            }
-            if (result != null && responseHeaderSize != null) {
-                result.getClass().getMethod("setResponseBufferSize", Integer.TYPE)
-                    .invoke(result, responseHeaderSize);
-            }
-            result.getClass().getMethod("setPort", Integer.TYPE).invoke(result, porto);
-            if (hosto != null) {
-                result.getClass().getMethod("setHost", String.class).invoke(result, hosto);
-            }
-        } catch (RuntimeException rex) {
-            throw rex;
-        } catch (Exception ex) {
-            throw new RuntimeException(ex);
-        }
-        return result;
-    }    
+    
+    protected abstract AbstractConnector createConnectorJettyInternal(Server server, JettyHttpEndpoint endpoint, SslContextFactory sslcf);
     
     private SslContextFactory createSslContextFactory(SSLContextParameters ssl) throws GeneralSecurityException, IOException {
         SslContextFactory answer = new SslContextFactory();
@@ -779,11 +613,11 @@ public abstract class JettyHttpComponent extends HttpComponent implements RestCo
         return false;
     }
 
-    public Map<Integer, SslContextFactory> getSslSocketConnectors() {
+    public Map<Integer, Connector> getSslSocketConnectors() {
         return sslSocketConnectors;
     }
 
-    public void setSslSocketConnectors(Map <Integer, SslContextFactory> connectors) {
+    public void setSslSocketConnectors(Map <Integer, Connector> connectors) {
         sslSocketConnectors = connectors;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
index 8cc89a2..6189ba6 100644
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpEndpoint.java
@@ -28,7 +28,6 @@ import org.apache.camel.Consumer;
 import org.apache.camel.Processor;
 import org.apache.camel.Producer;
 import org.apache.camel.ResolveEndpointFailedException;
-import org.apache.camel.component.http.HttpBinding;
 import org.apache.camel.component.http.HttpConsumer;
 import org.apache.camel.component.http.HttpEndpoint;
 import org.apache.camel.impl.SynchronousDelegateProducer;
@@ -79,10 +78,6 @@ public class JettyHttpEndpoint extends HttpEndpoint {
     public JettyHttpComponent getComponent() {
         return (JettyHttpComponent) super.getComponent();
     }
-    
-    public HttpBinding getBinding() {
-        return new AttachmentHttpBinding(this);
-    }
 
     @Override
     public Producer createProducer() throws Exception {

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
index 1bcbed0..d8c0d2b 100644
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty/JettyHttpProducer.java
@@ -34,10 +34,9 @@ import org.apache.camel.Message;
 import org.apache.camel.component.http.HttpConstants;
 import org.apache.camel.component.http.HttpMethods;
 import org.apache.camel.component.http.helper.HttpHelper;
-import org.apache.camel.component.jetty9.JettyContentExchange9;
-import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.component.jetty8.JettyContentExchange8;
+import org.apache.camel.impl.DefaultAsyncProducer;
 import org.apache.camel.spi.HeaderFilterStrategy;
-import org.apache.camel.util.AsyncProcessorHelper;
 import org.apache.camel.util.ExchangeHelper;
 import org.apache.camel.util.IOHelper;
 import org.apache.camel.util.ObjectHelper;
@@ -50,7 +49,7 @@ import org.slf4j.LoggerFactory;
 /**
  * @version 
  */
-public class JettyHttpProducer extends DefaultProducer implements AsyncProcessor {
+public class JettyHttpProducer extends DefaultAsyncProducer implements AsyncProcessor {
     private static final Logger LOG = LoggerFactory.getLogger(JettyHttpProducer.class);
     private HttpClient client;
     private boolean sharedClient;
@@ -84,10 +83,6 @@ public class JettyHttpProducer extends DefaultProducer implements AsyncProcessor
         return (JettyHttpEndpoint) super.getEndpoint();
     }
 
-    public void process(Exchange exchange) throws Exception {
-        AsyncProcessorHelper.process(this, exchange);
-    }
-
     public boolean process(Exchange exchange, final AsyncCallback callback) {
         try {
             JettyContentExchange httpExchange = createHttpExchange(exchange, callback);
@@ -121,7 +116,7 @@ public class JettyHttpProducer extends DefaultProducer implements AsyncProcessor
         HttpMethods methodToUse = HttpHelper.createMethod(exchange, getEndpoint(), exchange.getIn().getBody() != null);
         String method = methodToUse.createMethod(url).getName();
 
-        JettyContentExchange httpExchange = new JettyContentExchange9(exchange, getBinding(), client);
+        JettyContentExchange httpExchange = new JettyContentExchange8(exchange, getBinding(), client);
         httpExchange.setURL(url); // Url has to be set first
         httpExchange.setMethod(method);
         
@@ -171,6 +166,11 @@ public class JettyHttpProducer extends DefaultProducer implements AsyncProcessor
                     // then fallback to input stream
                     InputStream is = exchange.getContext().getTypeConverter().mandatoryConvertTo(InputStream.class, exchange, exchange.getIn().getBody());
                     httpExchange.setRequestContent(is);
+                    // setup the content length if it is possible
+                    String length = exchange.getIn().getHeader(Exchange.CONTENT_LENGTH, String.class);
+                    if (ObjectHelper.isNotEmpty(length)) {
+                        httpExchange.addRequestHeader(Exchange.CONTENT_LENGTH, length);
+                    }
                 }
             }
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/CamelHttpClient8.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/CamelHttpClient8.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/CamelHttpClient8.java
index bb00fe0..022bc72 100644
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/CamelHttpClient8.java
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/CamelHttpClient8.java
@@ -23,6 +23,7 @@ import org.eclipse.jetty.client.HttpClient;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
 import org.eclipse.jetty.util.thread.ThreadPool;
 
+@SuppressWarnings("unchecked")
 public class CamelHttpClient8 extends CamelHttpClient {
 
     public CamelHttpClient8(SslContextFactory sslContextFactory) {
@@ -30,6 +31,12 @@ public class CamelHttpClient8 extends CamelHttpClient {
         setConnectorType();
     }
     
+    @Override
+    protected void doStart() throws Exception {
+        setupRedirectListener();
+        super.doStart();
+    }
+
     private void setConnectorType() {
         try {
             HttpClient.class.getMethod("setConnectorType", Integer.TYPE).invoke(this, 2);
@@ -64,4 +71,13 @@ public class CamelHttpClient8 extends CamelHttpClient {
             throw new RuntimeException(t);
         }
     }
+
+    private void setupRedirectListener() {
+        // setup the listener for it
+        try {
+            getClass().getMethod("registerListener", String.class).invoke(this, CamelRedirectListener.class.getName());
+        } catch (Throwable t) {
+            throw new RuntimeException(t);
+        }
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/CamelRedirectListener.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/CamelRedirectListener.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/CamelRedirectListener.java
new file mode 100644
index 0000000..10ad17c
--- /dev/null
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/CamelRedirectListener.java
@@ -0,0 +1,52 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jetty8;
+
+import java.io.IOException;
+
+import org.eclipse.jetty.client.HttpDestination;
+import org.eclipse.jetty.client.HttpExchange;
+import org.eclipse.jetty.client.RedirectListener;
+import org.eclipse.jetty.http.HttpStatus;
+import org.eclipse.jetty.io.Buffer;
+
+public class CamelRedirectListener extends RedirectListener {
+    private final HttpExchange exchange;
+    
+    public CamelRedirectListener(HttpDestination destination, HttpExchange ex) {
+        super(destination, ex);
+        exchange = ex;
+    }
+
+    @Override
+    public void onResponseStatus(Buffer version, int status, Buffer reason) throws IOException {
+        // Update the exchange method to get to support the Post/Redirect/Get
+        // http://en.wikipedia.org/wiki/Post/Redirect/Get
+        if (exchange.getMethod().equals("POST") && (status == HttpStatus.SEE_OTHER_303 || status == HttpStatus.MOVED_TEMPORARILY_302)) {
+            exchange.setMethod("GET");
+        }
+        
+        // Since the default RedirectListener only cares about http
+        // response codes 301 and 302, we override this method and
+        // trick the super class into handling this case for us.
+        if (status == HttpStatus.SEE_OTHER_303) {
+            status = HttpStatus.MOVED_TEMPORARILY_302;
+        }
+
+        super.onResponseStatus(version, status, reason);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/JettyContentExchange8.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/JettyContentExchange8.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/JettyContentExchange8.java
new file mode 100644
index 0000000..5329021
--- /dev/null
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/JettyContentExchange8.java
@@ -0,0 +1,287 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jetty8;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.CountDownLatch;
+
+import org.apache.camel.AsyncCallback;
+import org.apache.camel.CamelExchangeException;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangeTimedOutException;
+import org.apache.camel.component.jetty.CamelHttpClient;
+import org.apache.camel.component.jetty.JettyContentExchange;
+import org.apache.camel.component.jetty.JettyHttpBinding;
+import org.apache.camel.util.IOHelper;
+import org.eclipse.jetty.client.ContentExchange;
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.HttpEventListener;
+import org.eclipse.jetty.client.HttpEventListenerWrapper;
+import org.eclipse.jetty.client.HttpExchange;
+import org.eclipse.jetty.http.HttpFields;
+import org.eclipse.jetty.http.HttpHeaders;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Jetty specific exchange which keeps track of the the request and response.
+ *
+ * @version 
+ */
+public class JettyContentExchange8 implements JettyContentExchange {
+
+    private static final Logger LOG = LoggerFactory.getLogger(JettyContentExchange8.class);
+
+    private volatile Exchange exchange;
+    private volatile AsyncCallback callback;
+    private volatile JettyHttpBinding jettyBinding;
+    private volatile HttpClient client;
+    private final CountDownLatch done = new CountDownLatch(1);
+    private final ContentExchange ce;
+
+    public JettyContentExchange8(Exchange exchange, JettyHttpBinding jettyBinding, 
+                                final HttpClient client) {
+        super(); // keep headers by default
+        this.exchange = exchange;
+        this.jettyBinding = jettyBinding;
+        this.client = client;
+        this.ce = new ContentExchange(true);
+        HttpEventListener old = ce.getEventListener();
+        ce.setEventListener(new HttpEventListenerWrapper(old, true) {
+            public void onRequestComplete() throws IOException {
+                JettyContentExchange8.this.onRequestComplete();
+                super.onRequestComplete();
+            }
+
+            @Override
+            public void onResponseComplete() throws IOException {
+                super.onResponseComplete();
+                JettyContentExchange8.this.onResponseComplete();
+            }
+
+            @Override
+            public void onConnectionFailed(Throwable ex) {
+                try {
+                    super.onConnectionFailed(ex);
+                } finally {
+                    JettyContentExchange8.this.onConnectionFailed(ex);
+                }
+            }
+
+            @Override
+            public void onException(Throwable ex) {
+                try {
+                    super.onException(ex);
+                } finally {
+                    JettyContentExchange8.this.onException(ex);
+                }
+            }
+
+            @Override
+            public void onExpire() {
+                try {
+                    super.onExpire();
+                } finally {
+                    JettyContentExchange8.this.onExpire();
+                }
+            }
+            
+        });
+    }
+
+    public void setCallback(AsyncCallback callback) {
+        this.callback = callback;
+    }
+
+    protected void onRequestComplete() throws IOException {
+        LOG.trace("onRequestComplete");
+        
+        closeRequestContentSource();
+    }
+
+    protected void onResponseComplete() throws IOException {
+        LOG.trace("onResponseComplete");
+        doTaskCompleted();
+    }
+
+    protected void onExpire() {
+        LOG.trace("onExpire");
+
+        // need to close the request input stream
+        closeRequestContentSource();
+        doTaskCompleted();
+    }
+
+    protected void onException(Throwable ex) {
+        LOG.trace("onException {}", ex);
+
+        // need to close the request input stream
+        closeRequestContentSource();
+        doTaskCompleted(ex);
+    }
+
+    protected void onConnectionFailed(Throwable ex) {
+        LOG.trace("onConnectionFailed {}", ex);
+
+        // need to close the request input stream
+        closeRequestContentSource();
+        doTaskCompleted(ex);
+    }
+
+    public byte[] getBody() {
+        // must return the content as raw bytes
+        return ce.getResponseContentBytes();
+    }
+
+    public String getUrl() {
+        String params = ce.getRequestFields().getStringField(HttpHeaders.CONTENT_ENCODING);
+        return ce.getScheme() + "://" 
+            + ce.getAddress().toString() 
+            + ce.getRequestURI() + (params != null ? "?" + params : "");
+    }
+    
+    protected void closeRequestContentSource() {
+        // close the input stream when its not needed anymore
+        InputStream is = ce.getRequestContentSource();
+        if (is != null) {
+            IOHelper.close(is, "RequestContentSource", LOG);
+        }
+    }
+
+    protected void doTaskCompleted() {
+        // make sure to lower the latch
+        done.countDown();
+
+        if (callback == null) {
+            // this is only for the async callback
+            return;
+        }
+
+        int exchangeState = ce.getStatus();
+
+        if (LOG.isDebugEnabled()) {
+            LOG.debug("TaskComplete with state {} for url: {}", exchangeState, getUrl());
+        }
+
+        try {
+            if (exchangeState == HttpExchange.STATUS_COMPLETED) {
+                // process the response as the state is ok
+                try {
+                    jettyBinding.populateResponse(exchange, this);
+                } catch (Exception e) {
+                    exchange.setException(e);
+                }
+            } else if (exchangeState == HttpExchange.STATUS_EXPIRED) {
+                // we did timeout
+                exchange.setException(new ExchangeTimedOutException(exchange, client.getTimeout()));
+            } else {
+                // some kind of other error
+                if (exchange.getException() != null) {
+                    exchange.setException(new CamelExchangeException("JettyClient failed with state " + exchangeState, exchange, exchange.getException()));
+                }
+            }
+        } finally {
+            // now invoke callback to indicate we are done async
+            callback.done(false);
+        }
+    }
+
+    protected void doTaskCompleted(Throwable ex) {
+        try {
+            // some kind of other error
+            exchange.setException(new CamelExchangeException("JettyClient failed cause by: " + ex.getMessage(), exchange, ex));
+        } finally {
+            // make sure to lower the latch
+            done.countDown();
+        }
+
+        if (callback != null) {
+            // now invoke callback to indicate we are done async
+            callback.done(false);
+        }
+    }
+
+    public void setRequestContentType(String contentType) {
+        ce.setRequestContentType(contentType);
+    }
+
+    public int getResponseStatus() {
+        return ce.getResponseStatus();
+    }
+
+    public void setMethod(String method) {
+        ce.setMethod(method);
+    }
+    
+    public void setURL(String url) {
+        ce.setURL(url);
+    }
+
+    public void setRequestContent(byte[] byteArray) {
+        ce.setRequestContent(new org.eclipse.jetty.io.ByteArrayBuffer(byteArray));        
+    }
+    public void setRequestContent(String data, String charset) throws UnsupportedEncodingException {
+        if (charset == null) {
+            ce.setRequestContent(new org.eclipse.jetty.io.ByteArrayBuffer(data));
+        } else {
+            ce.setRequestContent(new org.eclipse.jetty.io.ByteArrayBuffer(data, charset));
+        }
+    }
+    public void setRequestContent(InputStream ins) {
+        ce.setRequestContentSource(ins);        
+    }
+
+    public void addRequestHeader(String key, String s) {
+        ce.addRequestHeader(key, s);
+    }
+
+    public void send(HttpClient client) throws IOException {
+        client.send(ce);
+    }
+
+    public byte[] getResponseContentBytes() {
+        return ce.getResponseContentBytes();
+    }
+    
+    public Map<String, Collection<String>> getResponseHeaders() {
+        final HttpFields f = ce.getResponseFields();
+        Map<String, Collection<String>> ret = new TreeMap<String, Collection<String>>(String.CASE_INSENSITIVE_ORDER);
+        for (String n : f.getFieldNamesCollection()) {
+            ret.put(n,  f.getValuesCollection(n));
+        }
+        return ret;
+    }
+
+    @Override
+    public void setTimeout(long timeout) {
+        client.setTimeout(timeout);
+        ce.setTimeout(timeout);
+    }
+
+    @Override
+    public void setSupportRedirect(boolean supportRedirect) {
+        if (client instanceof CamelHttpClient) {
+            ((CamelHttpClient)client).setSupportRedirect(supportRedirect);
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/JettyHttpComponent8.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/JettyHttpComponent8.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/JettyHttpComponent8.java
index f228540..1cd9357 100644
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/JettyHttpComponent8.java
+++ b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty8/JettyHttpComponent8.java
@@ -16,8 +16,16 @@
  */
 package org.apache.camel.component.jetty8;
 
+import java.util.HashMap;
+import java.util.Map;
+
 import org.apache.camel.component.jetty.CamelHttpClient;
 import org.apache.camel.component.jetty.JettyHttpComponent;
+import org.apache.camel.component.jetty.JettyHttpEndpoint;
+import org.apache.camel.util.IntrospectionSupport;
+import org.apache.camel.util.ObjectHelper;
+import org.eclipse.jetty.server.AbstractConnector;
+import org.eclipse.jetty.server.Server;
 import org.eclipse.jetty.util.ssl.SslContextFactory;
 
 public class JettyHttpComponent8 extends JettyHttpComponent {
@@ -26,4 +34,92 @@ public class JettyHttpComponent8 extends JettyHttpComponent {
         return new CamelHttpClient8(sslContextFactory);
     }
 
+    protected AbstractConnector createConnectorJettyInternal(Server server,
+                                                      JettyHttpEndpoint endpoint,
+                                                      SslContextFactory sslcf) {
+        //Jetty 8
+        AbstractConnector result = null;
+        String hosto = endpoint.getHttpUri().getHost();
+        int porto = endpoint.getPort();
+        try {
+            if (sslcf == null && !"https".equals(endpoint.getProtocol())) { 
+                result = (AbstractConnector)ObjectHelper
+                    .loadClass("org.eclipse.jetty.server.nio.SelectChannelConnector",
+                               Server.class.getClassLoader()).newInstance();
+            } else if (sslcf == null) {
+                result = (AbstractConnector)ObjectHelper
+                    .loadClass("org.eclipse.jetty.server.ssl.SslSelectChannelConnector",
+                               Server.class.getClassLoader()).newInstance();
+            } else {
+                result = (AbstractConnector)ObjectHelper
+                    .loadClass("org.eclipse.jetty.server.ssl.SslSelectChannelConnector",
+                               Server.class.getClassLoader()).getConstructor(SslContextFactory.class)
+                               .newInstance(sslcf);
+            }
+            Server.class.getMethod("setSendServerVersion", Boolean.TYPE).invoke(server, 
+                                                                                endpoint.isSendServerVersion());
+            
+            Server.class.getMethod("setSendDateHeader", Boolean.TYPE).invoke(server, 
+                                                                             endpoint.isSendDateHeader());
+            
+            
+            if (result != null && requestBufferSize != null) {
+                result.getClass().getMethod("setRequestBufferSize", Integer.TYPE)
+                    .invoke(result, requestBufferSize);
+            }
+            if (result != null && requestHeaderSize != null) {
+                result.getClass().getMethod("setRequestHeaderSize", Integer.TYPE)
+                    .invoke(result, requestHeaderSize);
+            }
+            if (result != null && responseBufferSize != null) {
+                result.getClass().getMethod("setResponseBufferSize", Integer.TYPE)
+                    .invoke(result, responseBufferSize);
+            }
+            if (result != null && responseHeaderSize != null) {
+                result.getClass().getMethod("setResponseBufferSize", Integer.TYPE)
+                    .invoke(result, responseHeaderSize);
+            }
+            result.getClass().getMethod("setPort", Integer.TYPE).invoke(result, porto);
+            if (hosto != null) {
+                result.getClass().getMethod("setHost", String.class).invoke(result, hosto);
+            }
+        } catch (RuntimeException rex) {
+            throw rex;
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+        try {
+            result.getClass().getMethod("setPort", Integer.TYPE).invoke(result, porto);
+            if (hosto != null) {
+                result.getClass().getMethod("setHost", String.class).invoke(result, hosto);
+            }
+            if (getSocketConnectorProperties() != null && !"https".equals(endpoint.getProtocol())) {
+                // must copy the map otherwise it will be deleted
+                Map<String, Object> properties = new HashMap<String, Object>(getSocketConnectorProperties());
+                IntrospectionSupport.setProperties(result, properties);
+                if (properties.size() > 0) {
+                    throw new IllegalArgumentException("There are " + properties.size()
+                        + " parameters that couldn't be set on the SocketConnector."
+                        + " Check the uri if the parameters are spelt correctly and that they are properties of the SelectChannelConnector."
+                        + " Unknown parameters=[" + properties + "]");
+                }
+            } else if (getSslSocketConnectorProperties() != null && "https".equals(endpoint.getProtocol())) {
+                // must copy the map otherwise it will be deleted
+                Map<String, Object> properties = new HashMap<String, Object>(getSslSocketConnectorProperties());
+                IntrospectionSupport.setProperties(result, properties);
+                if (properties.size() > 0) {
+                    throw new IllegalArgumentException("There are " + properties.size()
+                        + " parameters that couldn't be set on the SocketConnector."
+                        + " Check the uri if the parameters are spelt correctly and that they are properties of the SelectChannelConnector."
+                        + " Unknown parameters=[" + properties + "]");
+                }                
+            }
+
+        } catch (RuntimeException rex) {
+            throw rex;
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+        return result;
+    }  
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/CamelHttpClient9.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/CamelHttpClient9.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/CamelHttpClient9.java
deleted file mode 100644
index b86b8e2..0000000
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/CamelHttpClient9.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty9;
-
-import java.util.concurrent.Executor;
-
-import org.apache.camel.component.jetty.CamelHttpClient;
-import org.eclipse.jetty.util.ssl.SslContextFactory;
-
-public class CamelHttpClient9 extends CamelHttpClient {
-    
-    public CamelHttpClient9(SslContextFactory sslContextFactory) {
-        super(sslContextFactory);
-    }
-
-    protected boolean hasThreadPool() {
-        return getExecutor() != null;
-    }
-
-    protected void setThreadPoolOrExecutor(Executor pool) {
-        setExecutor(pool);
-    }
-    
-    public void setProxy(String host, int port) {
-        getProxyConfiguration().getProxies().add(new org.eclipse.jetty.client.HttpProxy(host, port));
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyContentExchange9.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyContentExchange9.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyContentExchange9.java
deleted file mode 100644
index 8c881d8..0000000
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyContentExchange9.java
+++ /dev/null
@@ -1,304 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty9;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.net.MalformedURLException;
-import java.util.Collection;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.concurrent.CountDownLatch;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import org.apache.camel.AsyncCallback;
-import org.apache.camel.CamelExchangeException;
-import org.apache.camel.Exchange;
-import org.apache.camel.ExchangeTimedOutException;
-import org.apache.camel.component.jetty.JettyContentExchange;
-import org.apache.camel.component.jetty.JettyHttpBinding;
-import org.eclipse.jetty.client.HttpClient;
-import org.eclipse.jetty.client.api.Request;
-import org.eclipse.jetty.client.api.Response;
-import org.eclipse.jetty.client.api.Result;
-import org.eclipse.jetty.client.util.BufferingResponseListener;
-import org.eclipse.jetty.client.util.BytesContentProvider;
-import org.eclipse.jetty.client.util.InputStreamContentProvider;
-import org.eclipse.jetty.client.util.StringContentProvider;
-import org.eclipse.jetty.http.HttpFields;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Jetty specific exchange which keeps track of the the request and response.
- *
- * @version 
- */
-public class JettyContentExchange9 implements JettyContentExchange {
-
-    private static final Logger LOG = LoggerFactory.getLogger(JettyContentExchange9.class);
-
-    private volatile Exchange exchange;
-    private volatile AsyncCallback callback;
-    private volatile JettyHttpBinding jettyBinding;
-    private volatile HttpClient client;
-    private final CountDownLatch done = new CountDownLatch(1);
-    private Request request;
-    private Response response;
-    private byte[] responseContent;
-
-    private String requestContentType;
-
-    private boolean supportRedirect;
-
-    public JettyContentExchange9(Exchange exchange, JettyHttpBinding jettyBinding, 
-                                final HttpClient client) {
-        super(); // keep headers by default
-        this.exchange = exchange;
-        this.jettyBinding = jettyBinding;
-        this.client = client;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setCallback(org.apache.camel.AsyncCallback)
-     */
-    public void setCallback(AsyncCallback callback) {
-        this.callback = callback;
-    }
-
-    protected void onRequestComplete() {
-        LOG.trace("onRequestComplete");
-        closeRequestContentSource();
-    }
-
-    protected void onResponseComplete(Result result, byte[] content, String contentType) {
-        LOG.trace("onResponseComplete");
-        done.countDown();
-        this.response = result.getResponse();
-        this.responseContent = content;
-        if (callback == null) {
-            // this is only for the async callback
-            return;
-        }
-        try {
-            jettyBinding.populateResponse(exchange, this);
-        } catch (Exception e) {
-            exchange.setException(e);
-        } finally {
-            callback.done(false);
-        }
-    }
-
-    protected void onExpire() {
-        LOG.trace("onExpire");
-
-        // need to close the request input stream
-        closeRequestContentSource();
-        doTaskCompleted(new ExchangeTimedOutException(exchange, client.getConnectTimeout()));
-    }
-
-    protected void onException(Throwable ex) {
-        LOG.trace("onException {}", ex);
-
-        // need to close the request input stream
-        closeRequestContentSource();
-        doTaskCompleted(ex);
-    }
-
-    protected void onConnectionFailed(Throwable ex) {
-        LOG.trace("onConnectionFailed {}", ex);
-
-        // need to close the request input stream
-        closeRequestContentSource();
-        doTaskCompleted(ex);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#getBody()
-     */
-    public byte[] getBody() {
-        // must return the content as raw bytes
-        return getResponseContentBytes();
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#getUrl()
-     */
-    public String getUrl() {
-        try {
-            return this.request.getURI().toURL().toExternalForm();
-        } catch (MalformedURLException e) {
-            throw new IllegalStateException(e.getMessage(), e);
-        }
-    }
-    
-    protected void closeRequestContentSource() {
-        tryClose(this.request.getContent());
-    }
-    
-    private void tryClose(Object obj) {
-        if (obj instanceof Closeable) {
-            try {
-                ((Closeable)obj).close();
-            } catch (IOException e) {
-                // Ignore
-            }
-        }
-    }
-
-    protected void doTaskCompleted(Throwable ex) {
-        if (ex instanceof TimeoutException) {
-            exchange.setException(new ExchangeTimedOutException(exchange, request.getTimeout()));
-        } else {
-            exchange.setException(new CamelExchangeException("JettyClient failed cause by: " + ex.getMessage(), exchange, ex));
-        }
-        done.countDown();
-
-        if (callback != null) {
-            // now invoke callback to indicate we are done async
-            callback.done(false);
-        }
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setRequestContentType(java.lang.String)
-     */
-    public void setRequestContentType(String contentType) {
-        this.requestContentType = contentType;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#getResponseStatus()
-     */
-    public int getResponseStatus() {
-        return this.response.getStatus();
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setMethod(java.lang.String)
-     */
-    public void setMethod(String method) {
-        this.request.method(method);
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setTimeout(long)
-     */
-    public void setTimeout(long timeout) {
-        this.request.timeout(timeout, TimeUnit.MILLISECONDS);
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setURL(java.lang.String)
-     */
-    public void setURL(String url) {
-        this.request = client.newRequest(url);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setRequestContent(byte[])
-     */
-    public void setRequestContent(byte[] byteArray) {
-        this.request.content(new BytesContentProvider(byteArray), this.requestContentType);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setRequestContent(java.lang.String, java.lang.String)
-     */
-    public void setRequestContent(String data, String charset) throws UnsupportedEncodingException {
-        StringContentProvider cp = charset != null ? new StringContentProvider(data, charset) : new StringContentProvider(data);
-        this.request.content(cp, this.requestContentType);
-    }
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setRequestContent(java.io.InputStream)
-     */
-    public void setRequestContent(InputStream ins) {
-        this.request.content(new InputStreamContentProvider(ins), this.requestContentType);        
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#addRequestHeader(java.lang.String, java.lang.String)
-     */
-    public void addRequestHeader(String key, String s) {
-        this.request.header(key, s);
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#send(org.eclipse.jetty.client.HttpClient)
-     */
-    public void send(HttpClient client) throws IOException {
-        org.eclipse.jetty.client.api.Request.Listener listener = new Request.Listener.Adapter() {
-
-            @Override
-            public void onSuccess(Request request) {
-                onRequestComplete();
-            }
-
-            @Override
-            public void onFailure(Request request, Throwable failure) {
-                onConnectionFailed(failure);
-            }
-
-        };
-        BufferingResponseListener responseListener = new BufferingResponseListener() {
-
-            @Override
-            public void onComplete(Result result) {
-                if (result.isFailed()) {
-                    doTaskCompleted(result.getFailure());
-                } else {
-                    onResponseComplete(result, getContent(), getMediaType());
-                }
-            }
-        };
-        request.followRedirects(supportRedirect).listener(listener).send(responseListener);
-    }
-
-    protected void setResponse(Response response) {
-        this.response = response;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#getResponseContentBytes()
-     */
-    public byte[] getResponseContentBytes() {
-        return responseContent;
-    }
-    
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#getResponseHeaders()
-     */
-    public Map<String, Collection<String>> getResponseHeaders() {
-        final HttpFields f = response.getHeaders();
-        Map<String, Collection<String>> ret = new TreeMap<String, Collection<String>>(String.CASE_INSENSITIVE_ORDER);
-        for (String n : f.getFieldNamesCollection()) {
-            ret.put(n,  f.getValuesList(n));
-        }
-        return ret;
-    }
-
-    /* (non-Javadoc)
-     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setSupportRedirect(boolean)
-     */
-    public void setSupportRedirect(boolean supportRedirect) {
-        this.supportRedirect = supportRedirect;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyHttpComponent9.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyHttpComponent9.java b/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyHttpComponent9.java
deleted file mode 100644
index 23c8160..0000000
--- a/components/camel-jetty/src/main/java/org/apache/camel/component/jetty9/JettyHttpComponent9.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.camel.component.jetty9;
-
-import org.apache.camel.component.jetty.CamelHttpClient;
-import org.apache.camel.component.jetty.JettyHttpComponent;
-import org.eclipse.jetty.util.ssl.SslContextFactory;
-
-public class JettyHttpComponent9 extends JettyHttpComponent {
-
-    protected CamelHttpClient createCamelHttpClient(SslContextFactory sslContextFactory) {
-        return new CamelHttpClient9(sslContextFactory);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/AttachmentHttpBinding.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/AttachmentHttpBinding.java b/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/AttachmentHttpBinding.java
new file mode 100644
index 0000000..82ce70f
--- /dev/null
+++ b/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/AttachmentHttpBinding.java
@@ -0,0 +1,75 @@
+package org.apache.camel.component.jetty9;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Collection;
+
+import javax.activation.DataHandler;
+import javax.activation.DataSource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.Part;
+
+import org.apache.camel.component.http.DefaultHttpBinding;
+import org.apache.camel.component.http.HttpEndpoint;
+import org.apache.camel.component.http.HttpMessage;
+import org.eclipse.jetty.util.MultiPartInputStreamParser;
+
+final class AttachmentHttpBinding extends DefaultHttpBinding {
+    AttachmentHttpBinding(HttpEndpoint endpoint) {
+        super(endpoint);
+    }
+
+    @Override
+    protected void populateAttachments(HttpServletRequest request, HttpMessage message) {
+        Object object = request.getAttribute("org.eclipse.jetty.servlet.MultiPartFile.multiPartInputStream");
+        if (object instanceof MultiPartInputStreamParser) {
+                MultiPartInputStreamParser parser = (MultiPartInputStreamParser)object;
+                Collection<Part> parts;
+                try {
+                    parts = parser.getParts();
+                    for (Part part : parts) {
+                        String contentType = part.getContentType();
+                        if (!contentType.startsWith("application/octet-stream")) {
+                            continue;
+                        }
+                       
+                        DataSource ds = new PartDataSource(part);
+                        message.addAttachment(part.getName(), new DataHandler(ds));
+                    }
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+                
+                
+        }
+    }
+    
+    final class PartDataSource implements DataSource {
+        private final Part part;
+
+        PartDataSource(Part part) {
+            this.part = part;
+        }
+
+        @Override
+        public OutputStream getOutputStream() throws IOException {
+            return null;
+        }
+
+        @Override
+        public String getName() {
+            return part.getName();
+        }
+
+        @Override
+        public InputStream getInputStream() throws IOException {
+            return part.getInputStream();
+        }
+
+        @Override
+        public String getContentType() {
+            return part.getContentType();
+        }
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/CamelHttpClient9.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/CamelHttpClient9.java b/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/CamelHttpClient9.java
new file mode 100644
index 0000000..b86b8e2
--- /dev/null
+++ b/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/CamelHttpClient9.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jetty9;
+
+import java.util.concurrent.Executor;
+
+import org.apache.camel.component.jetty.CamelHttpClient;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
+
+public class CamelHttpClient9 extends CamelHttpClient {
+    
+    public CamelHttpClient9(SslContextFactory sslContextFactory) {
+        super(sslContextFactory);
+    }
+
+    protected boolean hasThreadPool() {
+        return getExecutor() != null;
+    }
+
+    protected void setThreadPoolOrExecutor(Executor pool) {
+        setExecutor(pool);
+    }
+    
+    public void setProxy(String host, int port) {
+        getProxyConfiguration().getProxies().add(new org.eclipse.jetty.client.HttpProxy(host, port));
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/JettyContentExchange9.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/JettyContentExchange9.java b/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/JettyContentExchange9.java
new file mode 100644
index 0000000..8c881d8
--- /dev/null
+++ b/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/JettyContentExchange9.java
@@ -0,0 +1,304 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jetty9;
+
+import java.io.Closeable;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.util.Collection;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+import org.apache.camel.AsyncCallback;
+import org.apache.camel.CamelExchangeException;
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangeTimedOutException;
+import org.apache.camel.component.jetty.JettyContentExchange;
+import org.apache.camel.component.jetty.JettyHttpBinding;
+import org.eclipse.jetty.client.HttpClient;
+import org.eclipse.jetty.client.api.Request;
+import org.eclipse.jetty.client.api.Response;
+import org.eclipse.jetty.client.api.Result;
+import org.eclipse.jetty.client.util.BufferingResponseListener;
+import org.eclipse.jetty.client.util.BytesContentProvider;
+import org.eclipse.jetty.client.util.InputStreamContentProvider;
+import org.eclipse.jetty.client.util.StringContentProvider;
+import org.eclipse.jetty.http.HttpFields;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Jetty specific exchange which keeps track of the the request and response.
+ *
+ * @version 
+ */
+public class JettyContentExchange9 implements JettyContentExchange {
+
+    private static final Logger LOG = LoggerFactory.getLogger(JettyContentExchange9.class);
+
+    private volatile Exchange exchange;
+    private volatile AsyncCallback callback;
+    private volatile JettyHttpBinding jettyBinding;
+    private volatile HttpClient client;
+    private final CountDownLatch done = new CountDownLatch(1);
+    private Request request;
+    private Response response;
+    private byte[] responseContent;
+
+    private String requestContentType;
+
+    private boolean supportRedirect;
+
+    public JettyContentExchange9(Exchange exchange, JettyHttpBinding jettyBinding, 
+                                final HttpClient client) {
+        super(); // keep headers by default
+        this.exchange = exchange;
+        this.jettyBinding = jettyBinding;
+        this.client = client;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setCallback(org.apache.camel.AsyncCallback)
+     */
+    public void setCallback(AsyncCallback callback) {
+        this.callback = callback;
+    }
+
+    protected void onRequestComplete() {
+        LOG.trace("onRequestComplete");
+        closeRequestContentSource();
+    }
+
+    protected void onResponseComplete(Result result, byte[] content, String contentType) {
+        LOG.trace("onResponseComplete");
+        done.countDown();
+        this.response = result.getResponse();
+        this.responseContent = content;
+        if (callback == null) {
+            // this is only for the async callback
+            return;
+        }
+        try {
+            jettyBinding.populateResponse(exchange, this);
+        } catch (Exception e) {
+            exchange.setException(e);
+        } finally {
+            callback.done(false);
+        }
+    }
+
+    protected void onExpire() {
+        LOG.trace("onExpire");
+
+        // need to close the request input stream
+        closeRequestContentSource();
+        doTaskCompleted(new ExchangeTimedOutException(exchange, client.getConnectTimeout()));
+    }
+
+    protected void onException(Throwable ex) {
+        LOG.trace("onException {}", ex);
+
+        // need to close the request input stream
+        closeRequestContentSource();
+        doTaskCompleted(ex);
+    }
+
+    protected void onConnectionFailed(Throwable ex) {
+        LOG.trace("onConnectionFailed {}", ex);
+
+        // need to close the request input stream
+        closeRequestContentSource();
+        doTaskCompleted(ex);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#getBody()
+     */
+    public byte[] getBody() {
+        // must return the content as raw bytes
+        return getResponseContentBytes();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#getUrl()
+     */
+    public String getUrl() {
+        try {
+            return this.request.getURI().toURL().toExternalForm();
+        } catch (MalformedURLException e) {
+            throw new IllegalStateException(e.getMessage(), e);
+        }
+    }
+    
+    protected void closeRequestContentSource() {
+        tryClose(this.request.getContent());
+    }
+    
+    private void tryClose(Object obj) {
+        if (obj instanceof Closeable) {
+            try {
+                ((Closeable)obj).close();
+            } catch (IOException e) {
+                // Ignore
+            }
+        }
+    }
+
+    protected void doTaskCompleted(Throwable ex) {
+        if (ex instanceof TimeoutException) {
+            exchange.setException(new ExchangeTimedOutException(exchange, request.getTimeout()));
+        } else {
+            exchange.setException(new CamelExchangeException("JettyClient failed cause by: " + ex.getMessage(), exchange, ex));
+        }
+        done.countDown();
+
+        if (callback != null) {
+            // now invoke callback to indicate we are done async
+            callback.done(false);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setRequestContentType(java.lang.String)
+     */
+    public void setRequestContentType(String contentType) {
+        this.requestContentType = contentType;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#getResponseStatus()
+     */
+    public int getResponseStatus() {
+        return this.response.getStatus();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setMethod(java.lang.String)
+     */
+    public void setMethod(String method) {
+        this.request.method(method);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setTimeout(long)
+     */
+    public void setTimeout(long timeout) {
+        this.request.timeout(timeout, TimeUnit.MILLISECONDS);
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setURL(java.lang.String)
+     */
+    public void setURL(String url) {
+        this.request = client.newRequest(url);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setRequestContent(byte[])
+     */
+    public void setRequestContent(byte[] byteArray) {
+        this.request.content(new BytesContentProvider(byteArray), this.requestContentType);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setRequestContent(java.lang.String, java.lang.String)
+     */
+    public void setRequestContent(String data, String charset) throws UnsupportedEncodingException {
+        StringContentProvider cp = charset != null ? new StringContentProvider(data, charset) : new StringContentProvider(data);
+        this.request.content(cp, this.requestContentType);
+    }
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setRequestContent(java.io.InputStream)
+     */
+    public void setRequestContent(InputStream ins) {
+        this.request.content(new InputStreamContentProvider(ins), this.requestContentType);        
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#addRequestHeader(java.lang.String, java.lang.String)
+     */
+    public void addRequestHeader(String key, String s) {
+        this.request.header(key, s);
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#send(org.eclipse.jetty.client.HttpClient)
+     */
+    public void send(HttpClient client) throws IOException {
+        org.eclipse.jetty.client.api.Request.Listener listener = new Request.Listener.Adapter() {
+
+            @Override
+            public void onSuccess(Request request) {
+                onRequestComplete();
+            }
+
+            @Override
+            public void onFailure(Request request, Throwable failure) {
+                onConnectionFailed(failure);
+            }
+
+        };
+        BufferingResponseListener responseListener = new BufferingResponseListener() {
+
+            @Override
+            public void onComplete(Result result) {
+                if (result.isFailed()) {
+                    doTaskCompleted(result.getFailure());
+                } else {
+                    onResponseComplete(result, getContent(), getMediaType());
+                }
+            }
+        };
+        request.followRedirects(supportRedirect).listener(listener).send(responseListener);
+    }
+
+    protected void setResponse(Response response) {
+        this.response = response;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#getResponseContentBytes()
+     */
+    public byte[] getResponseContentBytes() {
+        return responseContent;
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#getResponseHeaders()
+     */
+    public Map<String, Collection<String>> getResponseHeaders() {
+        final HttpFields f = response.getHeaders();
+        Map<String, Collection<String>> ret = new TreeMap<String, Collection<String>>(String.CASE_INSENSITIVE_ORDER);
+        for (String n : f.getFieldNamesCollection()) {
+            ret.put(n,  f.getValuesList(n));
+        }
+        return ret;
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.camel.component.jetty.JettyContentExchangeI#setSupportRedirect(boolean)
+     */
+    public void setSupportRedirect(boolean supportRedirect) {
+        this.supportRedirect = supportRedirect;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/JettyHttpComponent9.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/JettyHttpComponent9.java b/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/JettyHttpComponent9.java
new file mode 100644
index 0000000..ec53cdc
--- /dev/null
+++ b/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/JettyHttpComponent9.java
@@ -0,0 +1,140 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.jetty9;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.component.jetty.CamelHttpClient;
+import org.apache.camel.component.jetty.JettyHttpComponent;
+import org.apache.camel.component.jetty.JettyHttpEndpoint;
+import org.apache.camel.util.IntrospectionSupport;
+import org.eclipse.jetty.server.AbstractConnector;
+import org.eclipse.jetty.server.ConnectionFactory;
+import org.eclipse.jetty.server.Connector;
+import org.eclipse.jetty.server.HttpConnectionFactory;
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ServerConnector;
+import org.eclipse.jetty.server.SslConnectionFactory;
+import org.eclipse.jetty.util.ssl.SslContextFactory;
+
+public class JettyHttpComponent9 extends JettyHttpComponent {
+
+    protected CamelHttpClient createCamelHttpClient(SslContextFactory sslContextFactory) {
+        return new CamelHttpClient9(sslContextFactory);
+    }
+
+    protected JettyHttpEndpoint createEndpoint(URI endpointUri, URI httpUri) throws URISyntaxException {
+        return new JettyHttpEndpoint9(this, endpointUri.toString(), httpUri);
+    }
+    
+    protected Connector getSslSocketConnector(Server server, JettyHttpEndpoint endpoint) {
+        Connector answer = null;
+        /*
+        if (sslSocketConnectors != null) {
+            SslContextFactory con = sslSocketConnectors.get(endpoint.getPort());
+            if (con != null) {
+                SslConnectionFactory sslConnectionFactory = new SslConnectionFactory(con, null);
+                @SuppressWarnings("resource")
+                ServerConnector sc = new ServerConnector(server, sslConnectionFactory);
+                sc.setPort(endpoint.getPort());
+                sc.setHost(endpoint.getHttpUri().getHost());
+                answer = sc;
+            }
+        }
+        */
+        if (answer == null) {
+            answer = createConnector(server, endpoint);
+        }
+        return answer;
+    }
+    
+    protected AbstractConnector createConnectorJettyInternal(Server server,
+                                                      JettyHttpEndpoint endpoint,
+                                                      SslContextFactory sslcf) {
+        try {
+            String hosto = endpoint.getHttpUri().getHost();
+            int porto = endpoint.getPort();
+            org.eclipse.jetty.server.HttpConfiguration httpConfig = new org.eclipse.jetty.server.HttpConfiguration();
+            httpConfig.setSendServerVersion(endpoint.isSendServerVersion());
+            httpConfig.setSendDateHeader(endpoint.isSendDateHeader());
+            httpConfig.setSendDateHeader(endpoint.isSendDateHeader());
+            
+            if (requestBufferSize != null) {
+                // Does not work
+                //httpConfig.setRequestBufferSize(requestBufferSize);
+            }
+            if (requestHeaderSize != null) {
+                httpConfig.setRequestHeaderSize(requestHeaderSize);
+            }
+            if (responseBufferSize != null) {
+                httpConfig.setOutputBufferSize(responseBufferSize);
+            }
+            if (responseHeaderSize != null) {
+                httpConfig.setResponseHeaderSize(responseHeaderSize);
+            }
+            
+            HttpConnectionFactory httpFactory = new org.eclipse.jetty.server.HttpConnectionFactory(httpConfig); 
+
+            ArrayList<ConnectionFactory> connectionFactories = new ArrayList<ConnectionFactory>();
+            ServerConnector result = new org.eclipse.jetty.server.ServerConnector(server);
+            if (sslcf != null) {
+                httpConfig.addCustomizer(new org.eclipse.jetty.server.SecureRequestCustomizer());
+                SslConnectionFactory scf = new org.eclipse.jetty.server.SslConnectionFactory(sslcf, "HTTP/1.1");
+                connectionFactories.add(scf);
+                result.setDefaultProtocol("SSL-HTTP/1.1");
+            }
+            connectionFactories.add(httpFactory);
+            result.setConnectionFactories(connectionFactories);
+            result.setPort(porto);
+            if (hosto != null) {
+                result.setHost(hosto);
+            }
+            /*
+            if (getSocketConnectorProperties() != null && !"https".equals(endpoint.getProtocol())) {
+                // must copy the map otherwise it will be deleted
+                Map<String, Object> properties = new HashMap<String, Object>(getSocketConnectorProperties());
+                IntrospectionSupport.setProperties(httpConfig, properties);
+                if (properties.size() > 0) {
+                    throw new IllegalArgumentException("There are " + properties.size()
+                        + " parameters that couldn't be set on the SocketConnector."
+                        + " Check the uri if the parameters are spelt correctly and that they are properties of the SelectChannelConnector."
+                        + " Unknown parameters=[" + properties + "]");
+                }
+            } else*/
+            if (getSslSocketConnectorProperties() != null && "https".equals(endpoint.getProtocol())) {
+                // must copy the map otherwise it will be deleted
+                Map<String, Object> properties = new HashMap<String, Object>(getSslSocketConnectorProperties());
+                IntrospectionSupport.setProperties(sslcf, properties);
+                if (properties.size() > 0) {
+                    throw new IllegalArgumentException("There are " + properties.size()
+                        + " parameters that couldn't be set on the SocketConnector."
+                        + " Check the uri if the parameters are spelt correctly and that they are properties of the SelectChannelConnector."
+                        + " Unknown parameters=[" + properties + "]");
+                }                
+            }
+            return result;
+        } catch (RuntimeException rex) {
+            throw rex;
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java b/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java
new file mode 100644
index 0000000..6ea83a9
--- /dev/null
+++ b/components/camel-jetty/src/main/jetty9/org/apache/camel/component/jetty9/JettyHttpEndpoint9.java
@@ -0,0 +1,18 @@
+package org.apache.camel.component.jetty9;
+
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.camel.component.http.HttpBinding;
+import org.apache.camel.component.jetty.JettyHttpComponent;
+import org.apache.camel.component.jetty.JettyHttpEndpoint;
+
+public class JettyHttpEndpoint9 extends JettyHttpEndpoint {
+    public JettyHttpEndpoint9(JettyHttpComponent component, String uri, URI httpURL) throws URISyntaxException {
+        super(component, uri, httpURL);
+    }
+    
+    public HttpBinding getBinding() {
+        return new AttachmentHttpBinding(this);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/85c890f7/components/camel-jetty/src/main/resources/META-INF/services/org/apache/camel/component/jetty
----------------------------------------------------------------------
diff --git a/components/camel-jetty/src/main/resources/META-INF/services/org/apache/camel/component/jetty b/components/camel-jetty/src/main/resources/META-INF/services/org/apache/camel/component/jetty
index d3cc88d..13116dc 100644
--- a/components/camel-jetty/src/main/resources/META-INF/services/org/apache/camel/component/jetty
+++ b/components/camel-jetty/src/main/resources/META-INF/services/org/apache/camel/component/jetty
@@ -14,4 +14,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 #
-class=org.apache.camel.component.jetty9.JettyHttpComponent9
\ No newline at end of file
+class=org.apache.camel.component.jetty8.JettyHttpComponent8


Mime
View raw message