Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 143AB17D9E for ; Sun, 28 Sep 2014 06:18:22 +0000 (UTC) Received: (qmail 9558 invoked by uid 500); 28 Sep 2014 06:18:21 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 9488 invoked by uid 500); 28 Sep 2014 06:18:21 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 9468 invoked by uid 99); 28 Sep 2014 06:18:21 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 28 Sep 2014 06:18:21 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 8C5699B91B1; Sun, 28 Sep 2014 06:18:21 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ningjiang@apache.org To: commits@camel.apache.org Date: Sun, 28 Sep 2014 06:18:22 -0000 Message-Id: <94de3a485da04cc9b991205b3142243f@git.apache.org> In-Reply-To: <3f38c153ae0043ce9d7bd1a529d11c33@git.apache.org> References: <3f38c153ae0043ce9d7bd1a529d11c33@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/3] git commit: CAMEL-7848 merged the patch to camel-netty4-http 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/164d65e7 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/164d65e7 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/164d65e7 Branch: refs/heads/master Commit: 164d65e7b9ff3952b3c1a5734bef14c94a99a41f Parents: 4b8521f Author: Willem Jiang Authored: Sun Sep 28 14:11:33 2014 +0800 Committer: Willem Jiang Committed: Sun Sep 28 14:11:33 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/164d65e7/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 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 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/164d65e7/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 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 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 {