camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject [1/3] git commit: CAMEL-7848 merged the patch to camel-netty4-http
Date Sun, 28 Sep 2014 06:41:29 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.13.x ca14720c7 -> 229890c49
  refs/heads/camel-2.14.x fbc22e54c -> 56ce89dc1


CAMEL-7848 merged the patch to camel-netty4-http


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

Branch: refs/heads/camel-2.14.x
Commit: 9c9f0a00cd71adf6d281d7f2c6ed44f053f7c776
Parents: fbc22e5
Author: Willem Jiang <willem.jiang@gmail.com>
Authored: Sun Sep 28 14:11:33 2014 +0800
Committer: Willem Jiang <willem.jiang@gmail.com>
Committed: Sun Sep 28 14:32:43 2014 +0800

----------------------------------------------------------------------
 .../http/HttpClientInitializerFactory.java      | 24 +++++++++++++++++-
 .../http/HttpServerInitializerFactory.java      | 26 ++++++++++++++++++--
 2 files changed, 47 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/9c9f0a00/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
index 0cb4742..b19fcf1 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.component.netty4.http;
 
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 import javax.net.ssl.SSLContext;
@@ -28,6 +29,7 @@ import io.netty.handler.codec.http.HttpClientCodec;
 import io.netty.handler.codec.http.HttpObjectAggregator;
 import io.netty.handler.ssl.SslHandler;
 import io.netty.handler.timeout.ReadTimeoutHandler;
+import org.apache.camel.component.netty4.ChannelHandlerFactory;
 import org.apache.camel.component.netty4.ClientInitializerFactory;
 import org.apache.camel.component.netty4.NettyConfiguration;
 import org.apache.camel.component.netty4.NettyProducer;
@@ -82,7 +84,27 @@ public class HttpClientInitializerFactory extends ClientInitializerFactory
{
             LOG.debug("Client SSL handler configured and added as an interceptor against
the ChannelPipeline: {}", sslHandler);
             pipeline.addLast("ssl", sslHandler);
         }
+        
+        List<ChannelHandler> encoders = producer.getConfiguration().getEncoders();
+        for (int x = 0; x < encoders.size(); x++) {
+            ChannelHandler encoder = encoders.get(x);
+            if (encoder instanceof ChannelHandlerFactory) {
+                // use the factory to create a new instance of the channel as it may not
be shareable
+                encoder = ((ChannelHandlerFactory) encoder).newChannelHandler();
+            }
+            pipeline.addLast("encoder-" + x, encoder);
+        }
 
+        List<ChannelHandler> decoders = producer.getConfiguration().getDecoders();
+        for (int x = 0; x < decoders.size(); x++) {
+            ChannelHandler decoder = decoders.get(x);
+            if (decoder instanceof ChannelHandlerFactory) {
+                // use the factory to create a new instance of the channel as it may not
be shareable
+                decoder = ((ChannelHandlerFactory) decoder).newChannelHandler();
+            }
+            pipeline.addLast("decoder-" + x, decoder);
+        }
+        
         pipeline.addLast("http", new HttpClientCodec());
         pipeline.addLast("aggregator", new HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
 
@@ -93,7 +115,7 @@ public class HttpClientInitializerFactory extends ClientInitializerFactory
{
             ChannelHandler timeout = new ReadTimeoutHandler(producer.getConfiguration().getRequestTimeout(),
TimeUnit.MILLISECONDS);
             pipeline.addLast("timeout", timeout);
         }
-
+       
         // handler to route Camel messages
         pipeline.addLast("handler", new HttpClientChannelHandler(producer));
 

http://git-wip-us.apache.org/repos/asf/camel/blob/9c9f0a00/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
index a98aef0..6d61945 100644
--- a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
+++ b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
@@ -17,6 +17,8 @@
 package org.apache.camel.component.netty4.http;
 
 
+import java.util.List;
+
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLEngine;
 
@@ -30,6 +32,7 @@ import io.netty.handler.codec.http.HttpResponseEncoder;
 import io.netty.handler.ssl.SslHandler;
 import io.netty.util.concurrent.EventExecutorGroup;
 import org.apache.camel.CamelContext;
+import org.apache.camel.component.netty4.ChannelHandlerFactory;
 import org.apache.camel.component.netty4.NettyConsumer;
 import org.apache.camel.component.netty4.NettyServerBootstrapConfiguration;
 import org.apache.camel.component.netty4.ServerInitializerFactory;
@@ -83,6 +86,26 @@ public class HttpServerInitializerFactory extends ServerInitializerFactory
{
             LOG.debug("Server SSL handler configured and added as an interceptor against
the ChannelPipeline: {}", sslHandler);
             pipeline.addLast("ssl", sslHandler);
         }
+       
+        List<ChannelHandler> decoders = consumer.getConfiguration().getDecoders();
+        for (int x = 0; x < decoders.size(); x++) {
+            ChannelHandler decoder = decoders.get(x);
+            if (decoder instanceof ChannelHandlerFactory) {
+                // use the factory to create a new instance of the channel as it may not
be shareable
+                decoder = ((ChannelHandlerFactory) decoder).newChannelHandler();
+            }
+            pipeline.addLast("decoder-" + x, decoder);
+        }
+        
+        List<ChannelHandler> encoders = consumer.getConfiguration().getEncoders();
+        for (int x = 0; x < encoders.size(); x++) {
+            ChannelHandler encoder = encoders.get(x);
+            if (encoder instanceof ChannelHandlerFactory) {
+                // use the factory to create a new instance of the channel as it may not
be shareable
+                encoder = ((ChannelHandlerFactory) encoder).newChannelHandler();
+            }
+            pipeline.addLast("encoder-" + x, encoder);
+        }
 
         pipeline.addLast("decoder", new HttpRequestDecoder());
         pipeline.addLast("aggregator", new HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
@@ -91,7 +114,7 @@ public class HttpServerInitializerFactory extends ServerInitializerFactory
{
         if (supportCompressed()) {
             pipeline.addLast("deflater", new HttpContentCompressor());
         }
-
+        
         int port = consumer.getConfiguration().getPort();
         ChannelHandler handler = consumer.getEndpoint().getComponent().getMultiplexChannelHandler(port).getChannelHandler();
         
@@ -101,7 +124,6 @@ public class HttpServerInitializerFactory extends ServerInitializerFactory
{
         } else {
             pipeline.addLast("handler", handler);
         }
-        
     }
 
     private SSLContext createSSLContext(CamelContext camelContext, NettyServerBootstrapConfiguration
configuration) throws Exception {


Mime
View raw message