You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/09/28 08:41:31 UTC

[3/3] git commit: CAMEL-7848 Added support for registry's encoders and decoders

CAMEL-7848 Added support for registry's encoders and decoders


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

Branch: refs/heads/camel-2.13.x
Commit: 229890c49ce0aefdefa2d8dc17b12ae0abdc16ab
Parents: ca14720
Author: Willem Jiang <wi...@gmail.com>
Authored: Sun Sep 28 13:59:49 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Sun Sep 28 14:41:05 2014 +0800

----------------------------------------------------------------------
 .../netty/http/HttpClientPipelineFactory.java   | 24 +++++++++++++++++++-
 .../netty/http/HttpServerPipelineFactory.java   | 23 +++++++++++++++++++
 2 files changed, 46 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/229890c4/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
index b5d2d4d..846d690 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpClientPipelineFactory.java
@@ -16,11 +16,13 @@
  */
 package org.apache.camel.component.netty.http;
 
+import java.util.List;
 import java.util.concurrent.TimeUnit;
 
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLEngine;
 
+import org.apache.camel.component.netty.ChannelHandlerFactory;
 import org.apache.camel.component.netty.ClientPipelineFactory;
 import org.apache.camel.component.netty.NettyComponent;
 import org.apache.camel.component.netty.NettyConfiguration;
@@ -79,6 +81,26 @@ public class HttpClientPipelineFactory extends ClientPipelineFactory {
             LOG.debug("Client SSL handler configured and added as an interceptor against the ChannelPipeline: {}", sslHandler);
             pipeline.addLast("ssl", sslHandler);
         }
+        
+        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);
+        }
+        
+        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);
+        }
 
         pipeline.addLast("http", new HttpClientCodec());
 
@@ -89,7 +111,7 @@ public class HttpClientPipelineFactory extends ClientPipelineFactory {
             ChannelHandler timeout = new ReadTimeoutHandler(NettyComponent.getTimer(), 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/229890c4/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
index 5d705ad..37fc58b 100644
--- a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
+++ b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerPipelineFactory.java
@@ -16,10 +16,13 @@
  */
 package org.apache.camel.component.netty.http;
 
+import java.util.List;
+
 import javax.net.ssl.SSLContext;
 import javax.net.ssl.SSLEngine;
 
 import org.apache.camel.CamelContext;
+import org.apache.camel.component.netty.ChannelHandlerFactory;
 import org.apache.camel.component.netty.NettyConsumer;
 import org.apache.camel.component.netty.NettyServerBootstrapConfiguration;
 import org.apache.camel.component.netty.ServerPipelineFactory;
@@ -82,6 +85,26 @@ public class HttpServerPipelineFactory extends ServerPipelineFactory {
             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 HttpChunkAggregator(configuration.getChunkedMaxContentLength()));