Rename *PiplelineFactory to *InitializerFactory

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

Branch: refs/heads/master
Commit: 00b64c8ad617e86de6be005f939f354d598bc92e
Parents: 8cd7ceb
Author: Willem Jiang <willem.ji...@gmail.com>
Authored: Sun Sep 7 17:28:02 2014 +0800
Committer: Willem Jiang <willem.ji...@gmail.com>
Committed: Sun Sep 7 17:28:02 2014 +0800

----------------------------------------------------------------------
 .../http/DefaultNettySharedHttpServer.java      |   2 +-
 .../http/HttpClientInitializerFactory.java      | 165 ++++++++++++++++
 .../netty4/http/HttpClientPipelineFactory.java  | 165 ----------------
 .../http/HttpServerInitializerFactory.java      | 172 +++++++++++++++++
 .../netty4/http/HttpServerPipelineFactory.java  | 172 -----------------
 .../HttpServerSharedInitializerFactory.java     | 159 +++++++++++++++
 .../http/HttpServerSharedPipelineFactory.java   | 159 ---------------
 .../netty4/http/NettyHttpComponent.java         |   2 +-
 .../netty4/http/NettyHttpConfiguration.java     |   4 +-
 .../HttpServerMultiplexChannelHandler.java      |   4 +-
 .../netty4/ClientInitializerFactory.java        |  42 ++++
 .../component/netty4/ClientPipelineFactory.java |  42 ----
 .../netty4/DefaultClientInitializerFactory.java | 170 +++++++++++++++++
 .../netty4/DefaultClientPipelineFactory.java    | 170 -----------------
 .../netty4/DefaultServerInitializerFactory.java | 191 +++++++++++++++++++
 .../netty4/DefaultServerPipelineFactory.java    | 191 -------------------
 .../component/netty4/NettyConfiguration.java    |  10 +-
 .../camel/component/netty4/NettyConsumer.java   |   6 +-
 .../camel/component/netty4/NettyProducer.java   |   6 +-
 .../NettyServerBootstrapConfiguration.java      |   6 +-
 .../netty4/ServerInitializerFactory.java        |  43 +++++
 .../component/netty4/ServerPipelineFactory.java |  43 -----
 .../NettyCustomPipelineFactoryAsynchTest.java   |   8 +-
 .../NettyCustomPipelineFactorySynchTest.java    |   8 +-
 24 files changed, 969 insertions(+), 971 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/DefaultNettySharedHttpServer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/DefaultNettySharedHttpServer.java
 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/DefaultNettySharedHttpServer.java
index 3ad1fb1..74e2550 100644
--- 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/DefaultNettySharedHttpServer.java
+++ 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/DefaultNettySharedHttpServer.java
@@ -104,7 +104,7 @@ public class DefaultNettySharedHttpServer extends 
ServiceSupport implements Nett
         channelFactory = new HttpServerMultiplexChannelHandler();
         channelFactory.init(configuration.getPort());
 
-        ChannelInitializer<Channel> pipelineFactory = new 
HttpServerSharedPipelineFactory(configuration, channelFactory, classResolver);
+        ChannelInitializer<Channel> pipelineFactory = new 
HttpServerSharedInitializerFactory(configuration, channelFactory, 
classResolver);
 
         // thread factory and pattern
         String port = Matcher.quoteReplacement("" + configuration.getPort());

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/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
new file mode 100644
index 0000000..0cb4742
--- /dev/null
+++ 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientInitializerFactory.java
@@ -0,0 +1,165 @@
+/**
+ * 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.netty4.http;
+
+import java.util.concurrent.TimeUnit;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelPipeline;
+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.ClientInitializerFactory;
+import org.apache.camel.component.netty4.NettyConfiguration;
+import org.apache.camel.component.netty4.NettyProducer;
+import 
org.apache.camel.component.netty4.http.handlers.HttpClientChannelHandler;
+import org.apache.camel.component.netty4.ssl.SSLEngineFactory;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * {@link ClientInitializerFactory} for the Netty HTTP client.
+ */
+public class HttpClientInitializerFactory extends ClientInitializerFactory {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(HttpClientInitializerFactory.class);
+    protected NettyHttpConfiguration configuration;
+    private NettyHttpProducer producer;
+    private SSLContext sslContext;
+
+    public HttpClientInitializerFactory() {
+        // default constructor needed
+    }
+
+    public HttpClientInitializerFactory(NettyHttpProducer nettyProducer) {
+        this.producer = nettyProducer;
+        try {
+            this.sslContext = createSSLContext(producer);
+        } catch (Exception e) {
+            throw ObjectHelper.wrapRuntimeCamelException(e);
+        }
+
+        if (sslContext != null) {
+            LOG.info("Created SslContext {}", sslContext);
+        }
+        configuration = nettyProducer.getConfiguration();
+    }
+
+    @Override
+    public ClientInitializerFactory createPipelineFactory(NettyProducer 
nettyProducer) {
+        return new HttpClientInitializerFactory((NettyHttpProducer) 
nettyProducer);
+    }
+
+    @Override
+    protected void initChannel(Channel ch) throws Exception {
+        // create a new pipeline
+        ChannelPipeline pipeline = ch.pipeline();
+
+        SslHandler sslHandler = configureClientSSLOnDemand();
+        if (sslHandler != null) {
+            //TODO must close on SSL exception
+            //sslHandler.setCloseOnSSLException(true);
+            LOG.debug("Client SSL handler configured and added as an 
interceptor against the ChannelPipeline: {}", sslHandler);
+            pipeline.addLast("ssl", sslHandler);
+        }
+
+        pipeline.addLast("http", new HttpClientCodec());
+        pipeline.addLast("aggregator", new 
HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
+
+        if (producer.getConfiguration().getRequestTimeout() > 0) {
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Using request timeout {} millis", 
producer.getConfiguration().getRequestTimeout());
+            }
+            ChannelHandler timeout = new 
ReadTimeoutHandler(producer.getConfiguration().getRequestTimeout(), 
TimeUnit.MILLISECONDS);
+            pipeline.addLast("timeout", timeout);
+        }
+
+        // handler to route Camel messages
+        pipeline.addLast("handler", new HttpClientChannelHandler(producer));
+
+        
+    }
+
+    private SSLContext createSSLContext(NettyProducer producer) throws 
Exception {
+        NettyConfiguration configuration = producer.getConfiguration();
+
+        if (!configuration.isSsl()) {
+            return null;
+        }
+
+        SSLContext answer;
+
+        // create ssl context once
+        if (configuration.getSslContextParameters() != null) {
+            answer = 
configuration.getSslContextParameters().createSSLContext();
+        } else {
+            if (configuration.getKeyStoreFile() == null && 
configuration.getKeyStoreResource() == null) {
+                LOG.debug("keystorefile is null");
+            }
+            if (configuration.getTrustStoreFile() == null && 
configuration.getTrustStoreResource() == null) {
+                LOG.debug("truststorefile is null");
+            }
+            if (configuration.getPassphrase().toCharArray() == null) {
+                LOG.debug("passphrase is null");
+            }
+
+            SSLEngineFactory sslEngineFactory;
+            if (configuration.getKeyStoreFile() != null || 
configuration.getTrustStoreFile() != null) {
+                sslEngineFactory = new SSLEngineFactory();
+                answer = 
sslEngineFactory.createSSLContext(producer.getContext().getClassResolver(),
+                        configuration.getKeyStoreFormat(),
+                        configuration.getSecurityProvider(),
+                        "file:" + configuration.getKeyStoreFile().getPath(),
+                        "file:" + configuration.getTrustStoreFile().getPath(),
+                        configuration.getPassphrase().toCharArray());
+            } else {
+                sslEngineFactory = new SSLEngineFactory();
+                answer = 
sslEngineFactory.createSSLContext(producer.getContext().getClassResolver(),
+                        configuration.getKeyStoreFormat(),
+                        configuration.getSecurityProvider(),
+                        configuration.getKeyStoreResource(),
+                        configuration.getTrustStoreResource(),
+                        configuration.getPassphrase().toCharArray());
+            }
+        }
+
+        return answer;
+    }
+
+    private SslHandler configureClientSSLOnDemand() throws Exception {
+        if (!producer.getConfiguration().isSsl()) {
+            return null;
+        }
+
+        if (producer.getConfiguration().getSslHandler() != null) {
+            return producer.getConfiguration().getSslHandler();
+        } else if (sslContext != null) {
+            SSLEngine engine = sslContext.createSSLEngine();
+            engine.setUseClientMode(true);
+            return new SslHandler(engine);
+        }
+
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientPipelineFactory.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientPipelineFactory.java
 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientPipelineFactory.java
deleted file mode 100644
index cb6610c..0000000
--- 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpClientPipelineFactory.java
+++ /dev/null
@@ -1,165 +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.netty4.http;
-
-import java.util.concurrent.TimeUnit;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLEngine;
-
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandler;
-import io.netty.channel.ChannelPipeline;
-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.ClientPipelineFactory;
-import org.apache.camel.component.netty4.NettyConfiguration;
-import org.apache.camel.component.netty4.NettyProducer;
-import 
org.apache.camel.component.netty4.http.handlers.HttpClientChannelHandler;
-import org.apache.camel.component.netty4.ssl.SSLEngineFactory;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * {@link org.apache.camel.component.netty.ClientPipelineFactory} for the 
Netty HTTP client.
- */
-public class HttpClientPipelineFactory extends ClientPipelineFactory {
-
-    private static final Logger LOG = 
LoggerFactory.getLogger(HttpClientPipelineFactory.class);
-    protected NettyHttpConfiguration configuration;
-    private NettyHttpProducer producer;
-    private SSLContext sslContext;
-
-    public HttpClientPipelineFactory() {
-        // default constructor needed
-    }
-
-    public HttpClientPipelineFactory(NettyHttpProducer nettyProducer) {
-        this.producer = nettyProducer;
-        try {
-            this.sslContext = createSSLContext(producer);
-        } catch (Exception e) {
-            throw ObjectHelper.wrapRuntimeCamelException(e);
-        }
-
-        if (sslContext != null) {
-            LOG.info("Created SslContext {}", sslContext);
-        }
-        configuration = nettyProducer.getConfiguration();
-    }
-
-    @Override
-    public ClientPipelineFactory createPipelineFactory(NettyProducer 
nettyProducer) {
-        return new HttpClientPipelineFactory((NettyHttpProducer) 
nettyProducer);
-    }
-
-    @Override
-    protected void initChannel(Channel ch) throws Exception {
-        // create a new pipeline
-        ChannelPipeline pipeline = ch.pipeline();
-
-        SslHandler sslHandler = configureClientSSLOnDemand();
-        if (sslHandler != null) {
-            //TODO must close on SSL exception
-            //sslHandler.setCloseOnSSLException(true);
-            LOG.debug("Client SSL handler configured and added as an 
interceptor against the ChannelPipeline: {}", sslHandler);
-            pipeline.addLast("ssl", sslHandler);
-        }
-
-        pipeline.addLast("http", new HttpClientCodec());
-        pipeline.addLast("aggregator", new 
HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
-
-        if (producer.getConfiguration().getRequestTimeout() > 0) {
-            if (LOG.isTraceEnabled()) {
-                LOG.trace("Using request timeout {} millis", 
producer.getConfiguration().getRequestTimeout());
-            }
-            ChannelHandler timeout = new 
ReadTimeoutHandler(producer.getConfiguration().getRequestTimeout(), 
TimeUnit.MILLISECONDS);
-            pipeline.addLast("timeout", timeout);
-        }
-
-        // handler to route Camel messages
-        pipeline.addLast("handler", new HttpClientChannelHandler(producer));
-
-        
-    }
-
-    private SSLContext createSSLContext(NettyProducer producer) throws 
Exception {
-        NettyConfiguration configuration = producer.getConfiguration();
-
-        if (!configuration.isSsl()) {
-            return null;
-        }
-
-        SSLContext answer;
-
-        // create ssl context once
-        if (configuration.getSslContextParameters() != null) {
-            answer = 
configuration.getSslContextParameters().createSSLContext();
-        } else {
-            if (configuration.getKeyStoreFile() == null && 
configuration.getKeyStoreResource() == null) {
-                LOG.debug("keystorefile is null");
-            }
-            if (configuration.getTrustStoreFile() == null && 
configuration.getTrustStoreResource() == null) {
-                LOG.debug("truststorefile is null");
-            }
-            if (configuration.getPassphrase().toCharArray() == null) {
-                LOG.debug("passphrase is null");
-            }
-
-            SSLEngineFactory sslEngineFactory;
-            if (configuration.getKeyStoreFile() != null || 
configuration.getTrustStoreFile() != null) {
-                sslEngineFactory = new SSLEngineFactory();
-                answer = 
sslEngineFactory.createSSLContext(producer.getContext().getClassResolver(),
-                        configuration.getKeyStoreFormat(),
-                        configuration.getSecurityProvider(),
-                        "file:" + configuration.getKeyStoreFile().getPath(),
-                        "file:" + configuration.getTrustStoreFile().getPath(),
-                        configuration.getPassphrase().toCharArray());
-            } else {
-                sslEngineFactory = new SSLEngineFactory();
-                answer = 
sslEngineFactory.createSSLContext(producer.getContext().getClassResolver(),
-                        configuration.getKeyStoreFormat(),
-                        configuration.getSecurityProvider(),
-                        configuration.getKeyStoreResource(),
-                        configuration.getTrustStoreResource(),
-                        configuration.getPassphrase().toCharArray());
-            }
-        }
-
-        return answer;
-    }
-
-    private SslHandler configureClientSSLOnDemand() throws Exception {
-        if (!producer.getConfiguration().isSsl()) {
-            return null;
-        }
-
-        if (producer.getConfiguration().getSslHandler() != null) {
-            return producer.getConfiguration().getSslHandler();
-        } else if (sslContext != null) {
-            SSLEngine engine = sslContext.createSSLEngine();
-            engine.setUseClientMode(true);
-            return new SslHandler(engine);
-        }
-
-        return null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/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
new file mode 100644
index 0000000..524e697
--- /dev/null
+++ 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerInitializerFactory.java
@@ -0,0 +1,172 @@
+/**
+ * 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.netty4.http;
+
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelPipeline;
+import io.netty.handler.codec.http.HttpContentCompressor;
+import io.netty.handler.codec.http.HttpObjectAggregator;
+import io.netty.handler.codec.http.HttpRequestDecoder;
+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.NettyConsumer;
+import org.apache.camel.component.netty4.NettyServerBootstrapConfiguration;
+import org.apache.camel.component.netty4.ServerInitializerFactory;
+import org.apache.camel.component.netty4.ssl.SSLEngineFactory;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * {@link ServerInitializerFactory} for the Netty HTTP server.
+ */
+public class HttpServerInitializerFactory extends ServerInitializerFactory {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(HttpServerInitializerFactory.class);
+    protected NettyHttpConsumer consumer;
+    protected SSLContext sslContext;
+    protected NettyHttpConfiguration configuration;
+
+    public HttpServerInitializerFactory() {
+        // default constructor needed
+    }
+
+    public HttpServerInitializerFactory(NettyHttpConsumer nettyConsumer) {
+        this.consumer = nettyConsumer;
+        this.configuration = nettyConsumer.getConfiguration();
+        try {
+            this.sslContext = createSSLContext(consumer.getContext(), 
consumer.getConfiguration());
+        } catch (Exception e) {
+            throw ObjectHelper.wrapRuntimeCamelException(e);
+        }
+
+        if (sslContext != null) {
+            LOG.info("Created SslContext {}", sslContext);
+        }
+    }
+
+    @Override
+    public ServerInitializerFactory createPipelineFactory(NettyConsumer 
nettyConsumer) {
+        return new HttpServerInitializerFactory((NettyHttpConsumer) 
nettyConsumer);
+    }
+
+    @Override
+    protected void initChannel(Channel ch) throws Exception {
+        // create a new pipeline
+        ChannelPipeline pipeline = ch.pipeline();
+        
+        SslHandler sslHandler = configureServerSSLOnDemand();
+        if (sslHandler != null) {
+            //TODO must close on SSL exception
+            // sslHandler.setCloseOnSSLException(true);
+            LOG.debug("Server SSL handler configured and added as an 
interceptor against the ChannelPipeline: {}", sslHandler);
+            pipeline.addLast("ssl", sslHandler);
+        }
+
+        pipeline.addLast("decoder", new HttpRequestDecoder());
+        pipeline.addLast("aggregator", new 
HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
+
+        pipeline.addLast("encoder", new HttpResponseEncoder());
+        if (supportCompressed()) {
+            pipeline.addLast("deflater", new HttpContentCompressor());
+        }
+
+        int port = consumer.getConfiguration().getPort();
+        ChannelHandler handler = 
consumer.getEndpoint().getComponent().getMultiplexChannelHandler(port).getChannelHandler();
+        
+        if (consumer.getConfiguration().isOrderedThreadPoolExecutor()) {
+            EventExecutorGroup applicationExecutor = 
consumer.getEndpoint().getComponent().getExecutorService();
+            pipeline.addLast(applicationExecutor, "handler", handler);
+        } else {
+            pipeline.addLast("handler", handler);
+        }
+        
+    }
+
+    private SSLContext createSSLContext(CamelContext camelContext, 
NettyServerBootstrapConfiguration configuration) throws Exception {
+        if (!configuration.isSsl()) {
+            return null;
+        }
+
+        SSLContext answer;
+
+        // create ssl context once
+        if (configuration.getSslContextParameters() != null) {
+            answer = 
configuration.getSslContextParameters().createSSLContext();
+        } else {
+            if (configuration.getKeyStoreFile() == null && 
configuration.getKeyStoreResource() == null) {
+                LOG.debug("keystorefile is null");
+            }
+            if (configuration.getTrustStoreFile() == null && 
configuration.getTrustStoreResource() == null) {
+                LOG.debug("truststorefile is null");
+            }
+            if (configuration.getPassphrase().toCharArray() == null) {
+                LOG.debug("passphrase is null");
+            }
+
+            SSLEngineFactory sslEngineFactory;
+            if (configuration.getKeyStoreFile() != null || 
configuration.getTrustStoreFile() != null) {
+                sslEngineFactory = new SSLEngineFactory();
+                answer = 
sslEngineFactory.createSSLContext(camelContext.getClassResolver(),
+                        configuration.getKeyStoreFormat(),
+                        configuration.getSecurityProvider(),
+                        "file:" + configuration.getKeyStoreFile().getPath(),
+                        "file:" + configuration.getTrustStoreFile().getPath(),
+                        configuration.getPassphrase().toCharArray());
+            } else {
+                sslEngineFactory = new SSLEngineFactory();
+                answer = 
sslEngineFactory.createSSLContext(camelContext.getClassResolver(),
+                        configuration.getKeyStoreFormat(),
+                        configuration.getSecurityProvider(),
+                        configuration.getKeyStoreResource(),
+                        configuration.getTrustStoreResource(),
+                        configuration.getPassphrase().toCharArray());
+            }
+        }
+
+        return answer;
+    }
+
+    private SslHandler configureServerSSLOnDemand() throws Exception {
+        if (!consumer.getConfiguration().isSsl()) {
+            return null;
+        }
+
+        if (consumer.getConfiguration().getSslHandler() != null) {
+            return consumer.getConfiguration().getSslHandler();
+        } else if (sslContext != null) {
+            SSLEngine engine = sslContext.createSSLEngine();
+            engine.setUseClientMode(false);
+            
engine.setNeedClientAuth(consumer.getConfiguration().isNeedClientAuth());
+            return new SslHandler(engine);
+        }
+
+        return null;
+    }
+
+    private boolean supportCompressed() {
+        return consumer.getEndpoint().getConfiguration().isCompression();
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerPipelineFactory.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerPipelineFactory.java
 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerPipelineFactory.java
deleted file mode 100644
index 51ae265..0000000
--- 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerPipelineFactory.java
+++ /dev/null
@@ -1,172 +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.netty4.http;
-
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLEngine;
-
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandler;
-import io.netty.channel.ChannelPipeline;
-import io.netty.handler.codec.http.HttpContentCompressor;
-import io.netty.handler.codec.http.HttpObjectAggregator;
-import io.netty.handler.codec.http.HttpRequestDecoder;
-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.NettyConsumer;
-import org.apache.camel.component.netty4.NettyServerBootstrapConfiguration;
-import org.apache.camel.component.netty4.ServerPipelineFactory;
-import org.apache.camel.component.netty4.ssl.SSLEngineFactory;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * {@link ServerPipelineFactory} for the Netty HTTP server.
- */
-public class HttpServerPipelineFactory extends ServerPipelineFactory {
-
-    private static final Logger LOG = 
LoggerFactory.getLogger(HttpServerPipelineFactory.class);
-    protected NettyHttpConsumer consumer;
-    protected SSLContext sslContext;
-    protected NettyHttpConfiguration configuration;
-
-    public HttpServerPipelineFactory() {
-        // default constructor needed
-    }
-
-    public HttpServerPipelineFactory(NettyHttpConsumer nettyConsumer) {
-        this.consumer = nettyConsumer;
-        this.configuration = nettyConsumer.getConfiguration();
-        try {
-            this.sslContext = createSSLContext(consumer.getContext(), 
consumer.getConfiguration());
-        } catch (Exception e) {
-            throw ObjectHelper.wrapRuntimeCamelException(e);
-        }
-
-        if (sslContext != null) {
-            LOG.info("Created SslContext {}", sslContext);
-        }
-    }
-
-    @Override
-    public ServerPipelineFactory createPipelineFactory(NettyConsumer 
nettyConsumer) {
-        return new HttpServerPipelineFactory((NettyHttpConsumer) 
nettyConsumer);
-    }
-
-    @Override
-    protected void initChannel(Channel ch) throws Exception {
-        // create a new pipeline
-        ChannelPipeline pipeline = ch.pipeline();
-        
-        SslHandler sslHandler = configureServerSSLOnDemand();
-        if (sslHandler != null) {
-            //TODO must close on SSL exception
-            // sslHandler.setCloseOnSSLException(true);
-            LOG.debug("Server SSL handler configured and added as an 
interceptor against the ChannelPipeline: {}", sslHandler);
-            pipeline.addLast("ssl", sslHandler);
-        }
-
-        pipeline.addLast("decoder", new HttpRequestDecoder());
-        pipeline.addLast("aggregator", new 
HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
-
-        pipeline.addLast("encoder", new HttpResponseEncoder());
-        if (supportCompressed()) {
-            pipeline.addLast("deflater", new HttpContentCompressor());
-        }
-
-        int port = consumer.getConfiguration().getPort();
-        ChannelHandler handler = 
consumer.getEndpoint().getComponent().getMultiplexChannelHandler(port).getChannelHandler();
-        
-        if (consumer.getConfiguration().isOrderedThreadPoolExecutor()) {
-            EventExecutorGroup applicationExecutor = 
consumer.getEndpoint().getComponent().getExecutorService();
-            pipeline.addLast(applicationExecutor, "handler", handler);
-        } else {
-            pipeline.addLast("handler", handler);
-        }
-        
-    }
-
-    private SSLContext createSSLContext(CamelContext camelContext, 
NettyServerBootstrapConfiguration configuration) throws Exception {
-        if (!configuration.isSsl()) {
-            return null;
-        }
-
-        SSLContext answer;
-
-        // create ssl context once
-        if (configuration.getSslContextParameters() != null) {
-            answer = 
configuration.getSslContextParameters().createSSLContext();
-        } else {
-            if (configuration.getKeyStoreFile() == null && 
configuration.getKeyStoreResource() == null) {
-                LOG.debug("keystorefile is null");
-            }
-            if (configuration.getTrustStoreFile() == null && 
configuration.getTrustStoreResource() == null) {
-                LOG.debug("truststorefile is null");
-            }
-            if (configuration.getPassphrase().toCharArray() == null) {
-                LOG.debug("passphrase is null");
-            }
-
-            SSLEngineFactory sslEngineFactory;
-            if (configuration.getKeyStoreFile() != null || 
configuration.getTrustStoreFile() != null) {
-                sslEngineFactory = new SSLEngineFactory();
-                answer = 
sslEngineFactory.createSSLContext(camelContext.getClassResolver(),
-                        configuration.getKeyStoreFormat(),
-                        configuration.getSecurityProvider(),
-                        "file:" + configuration.getKeyStoreFile().getPath(),
-                        "file:" + configuration.getTrustStoreFile().getPath(),
-                        configuration.getPassphrase().toCharArray());
-            } else {
-                sslEngineFactory = new SSLEngineFactory();
-                answer = 
sslEngineFactory.createSSLContext(camelContext.getClassResolver(),
-                        configuration.getKeyStoreFormat(),
-                        configuration.getSecurityProvider(),
-                        configuration.getKeyStoreResource(),
-                        configuration.getTrustStoreResource(),
-                        configuration.getPassphrase().toCharArray());
-            }
-        }
-
-        return answer;
-    }
-
-    private SslHandler configureServerSSLOnDemand() throws Exception {
-        if (!consumer.getConfiguration().isSsl()) {
-            return null;
-        }
-
-        if (consumer.getConfiguration().getSslHandler() != null) {
-            return consumer.getConfiguration().getSslHandler();
-        } else if (sslContext != null) {
-            SSLEngine engine = sslContext.createSSLEngine();
-            engine.setUseClientMode(false);
-            
engine.setNeedClientAuth(consumer.getConfiguration().isNeedClientAuth());
-            return new SslHandler(engine);
-        }
-
-        return null;
-    }
-
-    private boolean supportCompressed() {
-        return consumer.getEndpoint().getConfiguration().isCompression();
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
new file mode 100644
index 0000000..44d3273
--- /dev/null
+++ 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedInitializerFactory.java
@@ -0,0 +1,159 @@
+/**
+ * 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.netty4.http;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelPipeline;
+import io.netty.handler.codec.http.HttpContentCompressor;
+import io.netty.handler.codec.http.HttpObjectAggregator;
+import io.netty.handler.codec.http.HttpRequestDecoder;
+import io.netty.handler.codec.http.HttpResponseEncoder;
+import io.netty.handler.ssl.SslHandler;
+import org.apache.camel.component.netty4.NettyConsumer;
+import org.apache.camel.component.netty4.ServerInitializerFactory;
+import org.apache.camel.component.netty4.ssl.SSLEngineFactory;
+import org.apache.camel.impl.DefaultClassResolver;
+import org.apache.camel.spi.ClassResolver;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * A shared {@link HttpServerInitializerFactory} for a shared Netty HTTP 
server.
+ *
+ * @see NettySharedHttpServer
+ */
+public class HttpServerSharedInitializerFactory extends 
HttpServerInitializerFactory {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(HttpServerSharedInitializerFactory.class);
+    private final NettySharedHttpServerBootstrapConfiguration configuration;
+    private final HttpServerConsumerChannelFactory channelFactory;
+    private final ClassResolver classResolver;
+    private SSLContext sslContext;
+
+    public 
HttpServerSharedInitializerFactory(NettySharedHttpServerBootstrapConfiguration 
configuration, HttpServerConsumerChannelFactory channelFactory,
+                                           ClassResolver classResolver) {
+        this.configuration = configuration;
+        this.channelFactory = channelFactory;
+        // fallback and use default resolver
+        this.classResolver = classResolver != null ? classResolver : new 
DefaultClassResolver();
+
+        try {
+            this.sslContext = createSSLContext();
+        } catch (Exception e) {
+            throw ObjectHelper.wrapRuntimeCamelException(e);
+        }
+
+        if (sslContext != null) {
+            LOG.info("Created SslContext {}", sslContext);
+        }
+    }
+
+    @Override
+    public ServerInitializerFactory createPipelineFactory(NettyConsumer 
nettyConsumer) {
+        throw new UnsupportedOperationException("Should not call this 
operation");
+    }
+
+    @Override
+    protected void initChannel(Channel ch) throws Exception {
+        // create a new pipeline
+        ChannelPipeline pipeline = ch.pipeline();
+
+        SslHandler sslHandler = configureServerSSLOnDemand();
+        if (sslHandler != null) {
+            LOG.debug("Server SSL handler configured and added as an 
interceptor against the ChannelPipeline: {}", sslHandler);
+            pipeline.addLast("ssl", sslHandler);
+        }
+
+        pipeline.addLast("decoder", new HttpRequestDecoder());
+        if (configuration.isChunked()) {
+            pipeline.addLast("aggregator", new 
HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
+        }
+        pipeline.addLast("encoder", new HttpResponseEncoder());
+        if (configuration.isCompression()) {
+            pipeline.addLast("deflater", new HttpContentCompressor());
+        }
+
+        pipeline.addLast("handler", channelFactory.getChannelHandler());
+        
+    }
+
+    private SSLContext createSSLContext() throws Exception {
+        if (!configuration.isSsl()) {
+            return null;
+        }
+
+        SSLContext answer;
+
+        // create ssl context once
+        if (configuration.getSslContextParameters() != null) {
+            answer = 
configuration.getSslContextParameters().createSSLContext();
+        } else {
+            if (configuration.getKeyStoreFile() == null && 
configuration.getKeyStoreResource() == null) {
+                LOG.debug("keystorefile is null");
+            }
+            if (configuration.getTrustStoreFile() == null && 
configuration.getTrustStoreResource() == null) {
+                LOG.debug("truststorefile is null");
+            }
+            if (configuration.getPassphrase().toCharArray() == null) {
+                LOG.debug("passphrase is null");
+            }
+
+            SSLEngineFactory sslEngineFactory;
+            if (configuration.getKeyStoreFile() != null || 
configuration.getTrustStoreFile() != null) {
+                sslEngineFactory = new SSLEngineFactory();
+                answer = sslEngineFactory.createSSLContext(classResolver,
+                        configuration.getKeyStoreFormat(),
+                        configuration.getSecurityProvider(),
+                        "file:" + configuration.getKeyStoreFile().getPath(),
+                        "file:" + configuration.getTrustStoreFile().getPath(),
+                        configuration.getPassphrase().toCharArray());
+            } else {
+                sslEngineFactory = new SSLEngineFactory();
+                answer = sslEngineFactory.createSSLContext(classResolver,
+                        configuration.getKeyStoreFormat(),
+                        configuration.getSecurityProvider(),
+                        configuration.getKeyStoreResource(),
+                        configuration.getTrustStoreResource(),
+                        configuration.getPassphrase().toCharArray());
+            }
+        }
+
+        return answer;
+    }
+
+    private SslHandler configureServerSSLOnDemand() throws Exception {
+        if (!configuration.isSsl()) {
+            return null;
+        }
+
+        if (configuration.getSslHandler() != null) {
+            return configuration.getSslHandler();
+        } else if (sslContext != null) {
+            SSLEngine engine = sslContext.createSSLEngine();
+            engine.setUseClientMode(false);
+            engine.setNeedClientAuth(configuration.isNeedClientAuth());
+            return new SslHandler(engine);
+        }
+
+        return null;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedPipelineFactory.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedPipelineFactory.java
 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedPipelineFactory.java
deleted file mode 100644
index 3f47ff9..0000000
--- 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/HttpServerSharedPipelineFactory.java
+++ /dev/null
@@ -1,159 +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.netty4.http;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLEngine;
-
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelPipeline;
-import io.netty.handler.codec.http.HttpContentCompressor;
-import io.netty.handler.codec.http.HttpObjectAggregator;
-import io.netty.handler.codec.http.HttpRequestDecoder;
-import io.netty.handler.codec.http.HttpResponseEncoder;
-import io.netty.handler.ssl.SslHandler;
-import org.apache.camel.component.netty4.NettyConsumer;
-import org.apache.camel.component.netty4.ServerPipelineFactory;
-import org.apache.camel.component.netty4.ssl.SSLEngineFactory;
-import org.apache.camel.impl.DefaultClassResolver;
-import org.apache.camel.spi.ClassResolver;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * A shared {@link org.apache.camel.component.netty.ServerPipelineFactory} for 
a shared Netty HTTP server.
- *
- * @see NettySharedHttpServer
- */
-public class HttpServerSharedPipelineFactory extends HttpServerPipelineFactory 
{
-
-    private static final Logger LOG = 
LoggerFactory.getLogger(HttpServerSharedPipelineFactory.class);
-    private final NettySharedHttpServerBootstrapConfiguration configuration;
-    private final HttpServerConsumerChannelFactory channelFactory;
-    private final ClassResolver classResolver;
-    private SSLContext sslContext;
-
-    public 
HttpServerSharedPipelineFactory(NettySharedHttpServerBootstrapConfiguration 
configuration, HttpServerConsumerChannelFactory channelFactory,
-                                           ClassResolver classResolver) {
-        this.configuration = configuration;
-        this.channelFactory = channelFactory;
-        // fallback and use default resolver
-        this.classResolver = classResolver != null ? classResolver : new 
DefaultClassResolver();
-
-        try {
-            this.sslContext = createSSLContext();
-        } catch (Exception e) {
-            throw ObjectHelper.wrapRuntimeCamelException(e);
-        }
-
-        if (sslContext != null) {
-            LOG.info("Created SslContext {}", sslContext);
-        }
-    }
-
-    @Override
-    public ServerPipelineFactory createPipelineFactory(NettyConsumer 
nettyConsumer) {
-        throw new UnsupportedOperationException("Should not call this 
operation");
-    }
-
-    @Override
-    protected void initChannel(Channel ch) throws Exception {
-        // create a new pipeline
-        ChannelPipeline pipeline = ch.pipeline();
-
-        SslHandler sslHandler = configureServerSSLOnDemand();
-        if (sslHandler != null) {
-            LOG.debug("Server SSL handler configured and added as an 
interceptor against the ChannelPipeline: {}", sslHandler);
-            pipeline.addLast("ssl", sslHandler);
-        }
-
-        pipeline.addLast("decoder", new HttpRequestDecoder());
-        if (configuration.isChunked()) {
-            pipeline.addLast("aggregator", new 
HttpObjectAggregator(configuration.getChunkedMaxContentLength()));
-        }
-        pipeline.addLast("encoder", new HttpResponseEncoder());
-        if (configuration.isCompression()) {
-            pipeline.addLast("deflater", new HttpContentCompressor());
-        }
-
-        pipeline.addLast("handler", channelFactory.getChannelHandler());
-        
-    }
-
-    private SSLContext createSSLContext() throws Exception {
-        if (!configuration.isSsl()) {
-            return null;
-        }
-
-        SSLContext answer;
-
-        // create ssl context once
-        if (configuration.getSslContextParameters() != null) {
-            answer = 
configuration.getSslContextParameters().createSSLContext();
-        } else {
-            if (configuration.getKeyStoreFile() == null && 
configuration.getKeyStoreResource() == null) {
-                LOG.debug("keystorefile is null");
-            }
-            if (configuration.getTrustStoreFile() == null && 
configuration.getTrustStoreResource() == null) {
-                LOG.debug("truststorefile is null");
-            }
-            if (configuration.getPassphrase().toCharArray() == null) {
-                LOG.debug("passphrase is null");
-            }
-
-            SSLEngineFactory sslEngineFactory;
-            if (configuration.getKeyStoreFile() != null || 
configuration.getTrustStoreFile() != null) {
-                sslEngineFactory = new SSLEngineFactory();
-                answer = sslEngineFactory.createSSLContext(classResolver,
-                        configuration.getKeyStoreFormat(),
-                        configuration.getSecurityProvider(),
-                        "file:" + configuration.getKeyStoreFile().getPath(),
-                        "file:" + configuration.getTrustStoreFile().getPath(),
-                        configuration.getPassphrase().toCharArray());
-            } else {
-                sslEngineFactory = new SSLEngineFactory();
-                answer = sslEngineFactory.createSSLContext(classResolver,
-                        configuration.getKeyStoreFormat(),
-                        configuration.getSecurityProvider(),
-                        configuration.getKeyStoreResource(),
-                        configuration.getTrustStoreResource(),
-                        configuration.getPassphrase().toCharArray());
-            }
-        }
-
-        return answer;
-    }
-
-    private SslHandler configureServerSSLOnDemand() throws Exception {
-        if (!configuration.isSsl()) {
-            return null;
-        }
-
-        if (configuration.getSslHandler() != null) {
-            return configuration.getSslHandler();
-        } else if (sslContext != null) {
-            SSLEngine engine = sslContext.createSSLEngine();
-            engine.setUseClientMode(false);
-            engine.setNeedClientAuth(configuration.isNeedClientAuth());
-            return new SslHandler(engine);
-        }
-
-        return null;
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
index 4c6225c..c9c212d 100644
--- 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
+++ 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpComponent.java
@@ -208,7 +208,7 @@ public class NettyHttpComponent extends NettyComponent 
implements HeaderFilterSt
         if (answer == null) {
             HttpServerConsumerChannelFactory channelFactory = 
getMultiplexChannelHandler(consumer.getConfiguration().getPort());
             answer = new HttpServerBootstrapFactory(channelFactory);
-            answer.init(getCamelContext(), consumer.getConfiguration(), new 
HttpServerPipelineFactory(consumer));
+            answer.init(getCamelContext(), consumer.getConfiguration(), new 
HttpServerInitializerFactory(consumer));
             bootstrapFactories.put(key, answer);
         }
         return answer;

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
index fd581fa..da4ba9d 100644
--- 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
+++ 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/NettyHttpConfiguration.java
@@ -47,8 +47,8 @@ public class NettyHttpConfiguration extends 
NettyConfiguration {
         // we need sync=true as http is request/reply by nature
         setSync(true);
         setReuseAddress(true);
-        setServerPipelineFactory(new HttpServerPipelineFactory());
-        setClientPipelineFactory(new HttpClientPipelineFactory());
+        setServerPipelineFactory(new HttpServerInitializerFactory());
+        setClientPipelineFactory(new HttpClientInitializerFactory());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
index 374a846..b83cd45 100644
--- 
a/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
+++ 
b/components/camel-netty4-http/src/main/java/org/apache/camel/component/netty4/http/handlers/HttpServerMultiplexChannelHandler.java
@@ -27,9 +27,7 @@ import io.netty.channel.ChannelHandler;
 import io.netty.channel.ChannelHandler.Sharable;
 import io.netty.channel.ChannelHandlerContext;
 import io.netty.channel.SimpleChannelInboundHandler;
-import io.netty.handler.codec.http.DefaultFullHttpResponse;
 import io.netty.handler.codec.http.DefaultHttpResponse;
-import io.netty.handler.codec.http.FullHttpRequest;
 import io.netty.handler.codec.http.HttpContent;
 import io.netty.handler.codec.http.HttpRequest;
 import io.netty.handler.codec.http.HttpResponse;
@@ -47,7 +45,7 @@ import static 
io.netty.handler.codec.http.HttpResponseStatus.NOT_FOUND;
 import static io.netty.handler.codec.http.HttpVersion.HTTP_1_1;
 
 /**
- * A multiplex {@link 
org.apache.camel.component.netty4.http.HttpServerPipelineFactory} which keeps a 
list of handlers, and delegates to the
+ * A multiplex {@link 
org.apache.camel.component.netty4.http.HttpServerInitializerFactory} which 
keeps a list of handlers, and delegates to the
  * target handler based on the http context path in the incoming request. This 
is used to allow to reuse
  * the same Netty consumer, allowing to have multiple routes on the same netty 
{@link io.netty.bootstrap.ServerBootstrap}
  */

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ClientInitializerFactory.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ClientInitializerFactory.java
 
b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ClientInitializerFactory.java
new file mode 100644
index 0000000..00ecf1a
--- /dev/null
+++ 
b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ClientInitializerFactory.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.netty4;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelPipeline;
+
+/**
+ * Factory to create {@link ChannelPipeline} for clients, eg {@link 
NettyProducer}.
+ * <p/>
+ * Implementators must support creating a new instance of this factory which 
is associated
+ * to the given {@link NettyProducer} using the {@link 
#createPipelineFactory(NettyProducer)}
+ * method.
+ *
+ * @see ChannelInitializer
+ */
+public abstract class ClientInitializerFactory extends 
ChannelInitializer<Channel> {
+
+    /**
+     * Creates a new {@link ClientInitializerFactory} using the given {@link 
NettyProducer}
+     *
+     * @param producer the associated producers
+     * @return the {@link ClientInitializerFactory} associated to the given 
producer.
+     */
+    public abstract ClientInitializerFactory 
createPipelineFactory(NettyProducer producer);
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ClientPipelineFactory.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ClientPipelineFactory.java
 
b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ClientPipelineFactory.java
deleted file mode 100644
index 318c6eb..0000000
--- 
a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ClientPipelineFactory.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.netty4;
-
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelInitializer;
-import io.netty.channel.ChannelPipeline;
-
-/**
- * Factory to create {@link ChannelPipeline} for clients, eg {@link 
NettyProducer}.
- * <p/>
- * Implementators must support creating a new instance of this factory which 
is associated
- * to the given {@link NettyProducer} using the {@link 
#createPipelineFactory(NettyProducer)}
- * method.
- *
- * @see ChannelInitializer
- */
-public abstract class ClientPipelineFactory extends 
ChannelInitializer<Channel> {
-
-    /**
-     * Creates a new {@link ClientPipelineFactory} using the given {@link 
NettyProducer}
-     *
-     * @param producer the associated producers
-     * @return the {@link ClientPipelineFactory} associated to the given 
producer.
-     */
-    public abstract ClientPipelineFactory createPipelineFactory(NettyProducer 
producer);
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultClientInitializerFactory.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultClientInitializerFactory.java
 
b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultClientInitializerFactory.java
new file mode 100644
index 0000000..d262e02
--- /dev/null
+++ 
b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultClientInitializerFactory.java
@@ -0,0 +1,170 @@
+/**
+ * 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.netty4;
+
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelPipeline;
+import io.netty.handler.ssl.SslHandler;
+import io.netty.handler.timeout.ReadTimeoutHandler;
+
+import org.apache.camel.component.netty4.handlers.ClientChannelHandler;
+import org.apache.camel.component.netty4.ssl.SSLEngineFactory;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DefaultClientInitializerFactory extends ClientInitializerFactory  
{
+    private static final Logger LOG = 
LoggerFactory.getLogger(DefaultClientInitializerFactory.class);
+
+    private final NettyProducer producer;
+    private SSLContext sslContext;
+
+    public DefaultClientInitializerFactory(NettyProducer producer) {
+        this.producer = producer;
+        try {
+            this.sslContext = createSSLContext(producer);
+        } catch (Exception e) {
+            throw ObjectHelper.wrapRuntimeCamelException(e);
+        }
+    }
+
+    protected void initChannel(Channel ch) throws Exception {
+        // create a new pipeline
+        ChannelPipeline channelPipeline = ch.pipeline();
+
+        SslHandler sslHandler = configureClientSSLOnDemand();
+        if (sslHandler != null) {
+            //TODO  must close on SSL exception
+            //sslHandler.setCloseOnSSLException(true);
+            LOG.debug("Client SSL handler configured and added to the 
ChannelPipeline: {}", sslHandler);
+            addToPipeline("ssl", channelPipeline, 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();
+            }
+            addToPipeline("decoder-" + x, channelPipeline, 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();
+            }
+            addToPipeline("encoder-" + x, channelPipeline, encoder);
+        }
+
+        // do we use request timeout?
+        if (producer.getConfiguration().getRequestTimeout() > 0) {
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("Using request timeout {} millis", 
producer.getConfiguration().getRequestTimeout());
+            }
+            ChannelHandler timeout = new 
ReadTimeoutHandler(producer.getConfiguration().getRequestTimeout(), 
TimeUnit.MILLISECONDS);
+            addToPipeline("timeout", channelPipeline, timeout);
+        }
+
+        // our handler must be added last
+        addToPipeline("handler", channelPipeline, new 
ClientChannelHandler(producer));
+
+        LOG.trace("Created ChannelPipeline: {}", channelPipeline);
+        
+    }
+
+    private void addToPipeline(String name, ChannelPipeline pipeline, 
ChannelHandler handler) {
+        pipeline.addLast(name, handler);
+    }
+
+    private SSLContext createSSLContext(NettyProducer producer) throws 
Exception {
+        NettyConfiguration configuration = producer.getConfiguration();
+
+        if (!configuration.isSsl()) {
+            return null;
+        }
+
+        SSLContext answer;
+
+        // create ssl context once
+        if (configuration.getSslContextParameters() != null) {
+            answer = 
configuration.getSslContextParameters().createSSLContext();
+        } else {
+            if (configuration.getKeyStoreFile() == null && 
configuration.getKeyStoreResource() == null) {
+                LOG.debug("keystorefile is null");
+            }
+            if (configuration.getTrustStoreFile() == null && 
configuration.getTrustStoreResource() == null) {
+                LOG.debug("truststorefile is null");
+            }
+            if (configuration.getPassphrase().toCharArray() == null) {
+                LOG.debug("passphrase is null");
+            }
+
+            SSLEngineFactory sslEngineFactory;
+            if (configuration.getKeyStoreFile() != null || 
configuration.getTrustStoreFile() != null) {
+                sslEngineFactory = new SSLEngineFactory();
+                answer = 
sslEngineFactory.createSSLContext(producer.getContext().getClassResolver(),
+                        configuration.getKeyStoreFormat(),
+                        configuration.getSecurityProvider(),
+                        "file:" + configuration.getKeyStoreFile().getPath(),
+                        "file:" + configuration.getTrustStoreFile().getPath(),
+                        configuration.getPassphrase().toCharArray());
+            } else {
+                sslEngineFactory = new SSLEngineFactory();
+                answer = 
sslEngineFactory.createSSLContext(producer.getContext().getClassResolver(),
+                        configuration.getKeyStoreFormat(),
+                        configuration.getSecurityProvider(),
+                        configuration.getKeyStoreResource(),
+                        configuration.getTrustStoreResource(),
+                        configuration.getPassphrase().toCharArray());
+            }
+        }
+
+        return answer;
+    }
+
+    private SslHandler configureClientSSLOnDemand() throws Exception {
+        if (!producer.getConfiguration().isSsl()) {
+            return null;
+        }
+
+        if (producer.getConfiguration().getSslHandler() != null) {
+            return producer.getConfiguration().getSslHandler();
+        } else if (sslContext != null) {
+            SSLEngine engine = sslContext.createSSLEngine();
+            engine.setUseClientMode(true);
+            return new SslHandler(engine);
+        }
+
+        return null;
+    }
+
+    @Override
+    public ClientInitializerFactory createPipelineFactory(NettyProducer 
producer) {
+        return new DefaultClientInitializerFactory(producer);
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultClientPipelineFactory.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultClientPipelineFactory.java
 
b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultClientPipelineFactory.java
deleted file mode 100644
index 3e5998a..0000000
--- 
a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultClientPipelineFactory.java
+++ /dev/null
@@ -1,170 +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.netty4;
-
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLEngine;
-
-import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandler;
-import io.netty.channel.ChannelPipeline;
-import io.netty.handler.ssl.SslHandler;
-import io.netty.handler.timeout.ReadTimeoutHandler;
-
-import org.apache.camel.component.netty4.handlers.ClientChannelHandler;
-import org.apache.camel.component.netty4.ssl.SSLEngineFactory;
-import org.apache.camel.util.ObjectHelper;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class DefaultClientPipelineFactory extends ClientPipelineFactory  {
-    private static final Logger LOG = 
LoggerFactory.getLogger(DefaultClientPipelineFactory.class);
-
-    private final NettyProducer producer;
-    private SSLContext sslContext;
-
-    public DefaultClientPipelineFactory(NettyProducer producer) {
-        this.producer = producer;
-        try {
-            this.sslContext = createSSLContext(producer);
-        } catch (Exception e) {
-            throw ObjectHelper.wrapRuntimeCamelException(e);
-        }
-    }
-
-    protected void initChannel(Channel ch) throws Exception {
-        // create a new pipeline
-        ChannelPipeline channelPipeline = ch.pipeline();
-
-        SslHandler sslHandler = configureClientSSLOnDemand();
-        if (sslHandler != null) {
-            //TODO  must close on SSL exception
-            //sslHandler.setCloseOnSSLException(true);
-            LOG.debug("Client SSL handler configured and added to the 
ChannelPipeline: {}", sslHandler);
-            addToPipeline("ssl", channelPipeline, 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();
-            }
-            addToPipeline("decoder-" + x, channelPipeline, 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();
-            }
-            addToPipeline("encoder-" + x, channelPipeline, encoder);
-        }
-
-        // do we use request timeout?
-        if (producer.getConfiguration().getRequestTimeout() > 0) {
-            if (LOG.isTraceEnabled()) {
-                LOG.trace("Using request timeout {} millis", 
producer.getConfiguration().getRequestTimeout());
-            }
-            ChannelHandler timeout = new 
ReadTimeoutHandler(producer.getConfiguration().getRequestTimeout(), 
TimeUnit.MILLISECONDS);
-            addToPipeline("timeout", channelPipeline, timeout);
-        }
-
-        // our handler must be added last
-        addToPipeline("handler", channelPipeline, new 
ClientChannelHandler(producer));
-
-        LOG.trace("Created ChannelPipeline: {}", channelPipeline);
-        
-    }
-
-    private void addToPipeline(String name, ChannelPipeline pipeline, 
ChannelHandler handler) {
-        pipeline.addLast(name, handler);
-    }
-
-    private SSLContext createSSLContext(NettyProducer producer) throws 
Exception {
-        NettyConfiguration configuration = producer.getConfiguration();
-
-        if (!configuration.isSsl()) {
-            return null;
-        }
-
-        SSLContext answer;
-
-        // create ssl context once
-        if (configuration.getSslContextParameters() != null) {
-            answer = 
configuration.getSslContextParameters().createSSLContext();
-        } else {
-            if (configuration.getKeyStoreFile() == null && 
configuration.getKeyStoreResource() == null) {
-                LOG.debug("keystorefile is null");
-            }
-            if (configuration.getTrustStoreFile() == null && 
configuration.getTrustStoreResource() == null) {
-                LOG.debug("truststorefile is null");
-            }
-            if (configuration.getPassphrase().toCharArray() == null) {
-                LOG.debug("passphrase is null");
-            }
-
-            SSLEngineFactory sslEngineFactory;
-            if (configuration.getKeyStoreFile() != null || 
configuration.getTrustStoreFile() != null) {
-                sslEngineFactory = new SSLEngineFactory();
-                answer = 
sslEngineFactory.createSSLContext(producer.getContext().getClassResolver(),
-                        configuration.getKeyStoreFormat(),
-                        configuration.getSecurityProvider(),
-                        "file:" + configuration.getKeyStoreFile().getPath(),
-                        "file:" + configuration.getTrustStoreFile().getPath(),
-                        configuration.getPassphrase().toCharArray());
-            } else {
-                sslEngineFactory = new SSLEngineFactory();
-                answer = 
sslEngineFactory.createSSLContext(producer.getContext().getClassResolver(),
-                        configuration.getKeyStoreFormat(),
-                        configuration.getSecurityProvider(),
-                        configuration.getKeyStoreResource(),
-                        configuration.getTrustStoreResource(),
-                        configuration.getPassphrase().toCharArray());
-            }
-        }
-
-        return answer;
-    }
-
-    private SslHandler configureClientSSLOnDemand() throws Exception {
-        if (!producer.getConfiguration().isSsl()) {
-            return null;
-        }
-
-        if (producer.getConfiguration().getSslHandler() != null) {
-            return producer.getConfiguration().getSslHandler();
-        } else if (sslContext != null) {
-            SSLEngine engine = sslContext.createSSLEngine();
-            engine.setUseClientMode(true);
-            return new SslHandler(engine);
-        }
-
-        return null;
-    }
-
-    @Override
-    public ClientPipelineFactory createPipelineFactory(NettyProducer producer) 
{
-        return new DefaultClientPipelineFactory(producer);
-    }
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultServerInitializerFactory.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultServerInitializerFactory.java
 
b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultServerInitializerFactory.java
new file mode 100644
index 0000000..855a753
--- /dev/null
+++ 
b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultServerInitializerFactory.java
@@ -0,0 +1,191 @@
+/**
+ * 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.netty4;
+
+import java.util.List;
+
+import javax.net.ssl.SSLContext;
+import javax.net.ssl.SSLEngine;
+
+import io.netty.channel.Channel;
+import io.netty.channel.ChannelHandler;
+import io.netty.channel.ChannelPipeline;
+import io.netty.handler.ssl.SslHandler;
+import io.netty.util.concurrent.EventExecutorGroup;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.component.netty4.handlers.ServerChannelHandler;
+import org.apache.camel.component.netty4.ssl.SSLEngineFactory;
+import org.apache.camel.util.ObjectHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DefaultServerInitializerFactory extends ServerInitializerFactory {
+    private static final Logger LOG = 
LoggerFactory.getLogger(DefaultServerInitializerFactory.class);
+
+    private NettyConsumer consumer;
+    private SSLContext sslContext;
+
+    @Deprecated
+    public DefaultServerInitializerFactory(NettyServerBootstrapConfiguration 
configuration) {
+        this.consumer = null;
+        try {
+            this.sslContext = createSSLContext(null, configuration);
+        } catch (Exception e) {
+            throw ObjectHelper.wrapRuntimeCamelException(e);
+        }
+
+        if (sslContext != null) {
+            LOG.info("Created SslContext {}", sslContext);
+        }
+    }
+
+    public DefaultServerInitializerFactory(NettyConsumer consumer) {
+        this.consumer = consumer;
+        try {
+            this.sslContext = createSSLContext(consumer.getContext(), 
consumer.getConfiguration());
+        } catch (Exception e) {
+            throw ObjectHelper.wrapRuntimeCamelException(e);
+        }
+
+        if (sslContext != null) {
+            LOG.info("Created SslContext {}", sslContext);
+        }
+    }
+
+    @Override
+    protected void initChannel(Channel ch) throws Exception {
+        // create a new pipeline
+        ChannelPipeline channelPipeline = ch.pipeline();
+
+        SslHandler sslHandler = configureServerSSLOnDemand();
+        if (sslHandler != null) {
+            //TODO  must close on SSL exception
+            //sslHandler.setCloseOnSSLException(true);
+            LOG.debug("Server SSL handler configured and added as an 
interceptor against the ChannelPipeline: {}", sslHandler);
+            addToPipeline("ssl", channelPipeline, sslHandler);
+        }
+
+        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();
+            }
+            addToPipeline("encoder-" + x, channelPipeline, encoder);
+        }
+
+        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();
+            }
+            addToPipeline("decoder-" + x, channelPipeline, decoder);
+        }
+
+        if (consumer.getConfiguration().isOrderedThreadPoolExecutor()) {
+            // Just use EventExecutorGroup from the Netty Component
+            EventExecutorGroup applicationExecutor = 
consumer.getEndpoint().getComponent().getExecutorService();
+            addToPipeline("handler", channelPipeline, applicationExecutor, new 
ServerChannelHandler(consumer));
+    
+        } else {
+            // still use the worker event loop group here
+            addToPipeline("handler", channelPipeline, new 
ServerChannelHandler(consumer));
+
+        }
+        LOG.trace("Created ChannelPipeline: {}", channelPipeline);
+
+    }
+
+    private void addToPipeline(String name, ChannelPipeline pipeline, 
ChannelHandler handler) {
+        pipeline.addLast(name, handler);
+    }
+    
+    private void addToPipeline(String name, ChannelPipeline pipeline, 
EventExecutorGroup executor, ChannelHandler handler) {
+        pipeline.addLast(executor, name, handler);
+    }
+
+    private SSLContext createSSLContext(CamelContext camelContext, 
NettyServerBootstrapConfiguration configuration) throws Exception {
+        if (!configuration.isSsl()) {
+            return null;
+        }
+
+        SSLContext answer;
+
+        // create ssl context once
+        if (configuration.getSslContextParameters() != null) {
+            answer = 
configuration.getSslContextParameters().createSSLContext();
+        } else {
+            if (configuration.getKeyStoreFile() == null && 
configuration.getKeyStoreResource() == null) {
+                LOG.debug("keystorefile is null");
+            }
+            if (configuration.getTrustStoreFile() == null && 
configuration.getTrustStoreResource() == null) {
+                LOG.debug("truststorefile is null");
+            }
+            if (configuration.getPassphrase().toCharArray() == null) {
+                LOG.debug("passphrase is null");
+            }
+
+            SSLEngineFactory sslEngineFactory;
+            if (configuration.getKeyStoreFile() != null || 
configuration.getTrustStoreFile() != null) {
+                sslEngineFactory = new SSLEngineFactory();
+                answer = 
sslEngineFactory.createSSLContext(camelContext.getClassResolver(),
+                        configuration.getKeyStoreFormat(),
+                        configuration.getSecurityProvider(),
+                        "file:" + configuration.getKeyStoreFile().getPath(),
+                        "file:" + configuration.getTrustStoreFile().getPath(),
+                        configuration.getPassphrase().toCharArray());
+            } else {
+                sslEngineFactory = new SSLEngineFactory();
+                answer = 
sslEngineFactory.createSSLContext(camelContext.getClassResolver(),
+                        configuration.getKeyStoreFormat(),
+                        configuration.getSecurityProvider(),
+                        configuration.getKeyStoreResource(),
+                        configuration.getTrustStoreResource(),
+                        configuration.getPassphrase().toCharArray());
+            }
+        }
+
+        return answer;
+    }
+
+    private SslHandler configureServerSSLOnDemand() throws Exception {
+        if (!consumer.getConfiguration().isSsl()) {
+            return null;
+        }
+
+        if (consumer.getConfiguration().getSslHandler() != null) {
+            return consumer.getConfiguration().getSslHandler();
+        } else if (sslContext != null) {
+            SSLEngine engine = sslContext.createSSLEngine();
+            engine.setUseClientMode(false);
+            
engine.setNeedClientAuth(consumer.getConfiguration().isNeedClientAuth());
+            return new SslHandler(engine);
+        }
+
+        return null;
+    }
+
+    @Override
+    public ServerInitializerFactory createPipelineFactory(NettyConsumer 
consumer) {
+        return new DefaultServerInitializerFactory(consumer);
+    }
+
+}

Reply via email to