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/07 11:28:30 UTC

[1/2] Rename *PiplelineFactory to *InitializerFactory

Repository: camel
Updated Branches:
  refs/heads/master 8cd7ceb7b -> 00b64c8ad


http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultServerPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultServerPipelineFactory.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultServerPipelineFactory.java
deleted file mode 100644
index 92c1b21..0000000
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/DefaultServerPipelineFactory.java
+++ /dev/null
@@ -1,191 +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 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 DefaultServerPipelineFactory extends ServerPipelineFactory {
-    private static final Logger LOG = LoggerFactory.getLogger(DefaultServerPipelineFactory.class);
-
-    private NettyConsumer consumer;
-    private SSLContext sslContext;
-
-    @Deprecated
-    public DefaultServerPipelineFactory(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 DefaultServerPipelineFactory(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 ServerPipelineFactory createPipelineFactory(NettyConsumer consumer) {
-        return new DefaultServerPipelineFactory(consumer);
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java
index 2912a46..dbcab81 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConfiguration.java
@@ -75,7 +75,7 @@ public class NettyConfiguration extends NettyServerBootstrapConfiguration implem
     @UriParam
     private boolean allowDefaultCodec = true;
     @UriParam
-    private ClientPipelineFactory clientPipelineFactory;
+    private ClientInitializerFactory clientPipelineFactory;
     @UriParam
     private int maximumPoolSize = 16;
     @UriParam
@@ -167,8 +167,8 @@ public class NettyConfiguration extends NettyServerBootstrapConfiguration implem
         trustStoreFile = component.getAndRemoveOrResolveReferenceParameter(parameters, "trustStoreFile", File.class, trustStoreFile);
         keyStoreResource = component.getAndRemoveOrResolveReferenceParameter(parameters, "keyStoreResource", String.class, keyStoreResource);
         trustStoreResource = component.getAndRemoveOrResolveReferenceParameter(parameters, "trustStoreResource", String.class, trustStoreResource);
-        clientPipelineFactory = component.getAndRemoveOrResolveReferenceParameter(parameters, "clientPipelineFactory", ClientPipelineFactory.class, clientPipelineFactory);
-        serverPipelineFactory = component.getAndRemoveOrResolveReferenceParameter(parameters, "serverPipelineFactory", ServerPipelineFactory.class, serverPipelineFactory);
+        clientPipelineFactory = component.getAndRemoveOrResolveReferenceParameter(parameters, "clientPipelineFactory", ClientInitializerFactory.class, clientPipelineFactory);
+        serverPipelineFactory = component.getAndRemoveOrResolveReferenceParameter(parameters, "serverPipelineFactory", ServerInitializerFactory.class, serverPipelineFactory);
 
         // set custom encoders and decoders first
         List<ChannelHandler> referencedEncoders = component.resolveAndRemoveReferenceListParameter(parameters, "encoders", ChannelHandler.class, null);
@@ -389,11 +389,11 @@ public class NettyConfiguration extends NettyServerBootstrapConfiguration implem
         this.allowDefaultCodec = allowDefaultCodec;
     }
 
-    public void setClientPipelineFactory(ClientPipelineFactory clientPipelineFactory) {
+    public void setClientPipelineFactory(ClientInitializerFactory clientPipelineFactory) {
         this.clientPipelineFactory = clientPipelineFactory;
     }
 
-    public ClientPipelineFactory getClientPipelineFactory() {
+    public ClientInitializerFactory getClientPipelineFactory() {
         return clientPipelineFactory;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConsumer.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConsumer.java
index 2714bcc..82e95ed 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConsumer.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyConsumer.java
@@ -50,12 +50,12 @@ public class NettyConsumer extends DefaultConsumer {
 
         if (nettyServerBootstrapFactory == null) {
             // setup pipeline factory
-            ServerPipelineFactory pipelineFactory;
-            ServerPipelineFactory factory = configuration.getServerPipelineFactory();
+            ServerInitializerFactory pipelineFactory;
+            ServerInitializerFactory factory = configuration.getServerPipelineFactory();
             if (factory != null) {
                 pipelineFactory = factory.createPipelineFactory(this);
             } else {
-                pipelineFactory = new DefaultServerPipelineFactory(this);
+                pipelineFactory = new DefaultServerInitializerFactory(this);
             }
 
             if (isTcp()) {

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyProducer.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyProducer.java
index 2183f6f..53b777f 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyProducer.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyProducer.java
@@ -59,7 +59,7 @@ public class NettyProducer extends DefaultAsyncProducer {
     private final ChannelGroup allChannels = new DefaultChannelGroup("NettyProducer", ImmediateEventExecutor.INSTANCE);
     private CamelContext context;
     private NettyConfiguration configuration;
-    private ClientPipelineFactory pipelineFactory;
+    private ClientInitializerFactory pipelineFactory;
     private CamelLogger noReplyLogger;
     private EventLoopGroup workerGroup;
     private ObjectPool<Channel> pool;
@@ -125,11 +125,11 @@ public class NettyProducer extends DefaultAsyncProducer {
         timer = new HashedWheelTimer();
 
         // setup pipeline factory
-        ClientPipelineFactory factory = configuration.getClientPipelineFactory();
+        ClientInitializerFactory factory = configuration.getClientPipelineFactory();
         if (factory != null) {
             pipelineFactory = factory.createPipelineFactory(this);
         } else {
-            pipelineFactory = new DefaultClientPipelineFactory(this);
+            pipelineFactory = new DefaultClientInitializerFactory(this);
         }
 
         if (!configuration.isLazyChannelCreation()) {

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
index bf55073..8380849 100644
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/NettyServerBootstrapConfiguration.java
@@ -40,7 +40,7 @@ public class NettyServerBootstrapConfiguration implements Cloneable {
     protected boolean reuseAddress = true;
     protected int connectTimeout = 10000;
     protected int backlog;
-    protected ServerPipelineFactory serverPipelineFactory;
+    protected ServerInitializerFactory serverPipelineFactory;
     protected NettyServerBootstrapFactory nettyServerBootstrapFactory;
     protected Map<String, Object> options;
     // SSL options is also part of the server bootstrap as the server listener on port X is either plain or SSL
@@ -280,11 +280,11 @@ public class NettyServerBootstrapConfiguration implements Cloneable {
         this.passphrase = passphrase;
     }
 
-    public ServerPipelineFactory getServerPipelineFactory() {
+    public ServerInitializerFactory getServerPipelineFactory() {
         return serverPipelineFactory;
     }
 
-    public void setServerPipelineFactory(ServerPipelineFactory serverPipelineFactory) {
+    public void setServerPipelineFactory(ServerInitializerFactory serverPipelineFactory) {
         this.serverPipelineFactory = serverPipelineFactory;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ServerInitializerFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ServerInitializerFactory.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ServerInitializerFactory.java
new file mode 100644
index 0000000..3fea1b2
--- /dev/null
+++ b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ServerInitializerFactory.java
@@ -0,0 +1,43 @@
+/**
+ * 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 servers, eg {@link NettyConsumer}.
+ * <p/>
+ * Implementators must support creating a new instance of this factory which is associated
+ * to the given {@link NettyConsumer} using the {@link #createPipelineFactory(NettyConsumer)}
+ * method.
+ *
+ * @see ChannelPipelineFactory
+ */
+public abstract class ServerInitializerFactory extends ChannelInitializer<Channel> {
+
+    /**
+     * Creates a new {@link ServerInitializerFactory} using the given {@link NettyConsumer}
+     *
+     * @param consumer the associated consumer
+     * @return the {@link ServerInitializerFactory} associated to the given consumer.
+     */
+    public abstract ServerInitializerFactory createPipelineFactory(NettyConsumer consumer);
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ServerPipelineFactory.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ServerPipelineFactory.java b/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ServerPipelineFactory.java
deleted file mode 100644
index 9d731e0..0000000
--- a/components/camel-netty4/src/main/java/org/apache/camel/component/netty4/ServerPipelineFactory.java
+++ /dev/null
@@ -1,43 +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 servers, eg {@link NettyConsumer}.
- * <p/>
- * Implementators must support creating a new instance of this factory which is associated
- * to the given {@link NettyConsumer} using the {@link #createPipelineFactory(NettyConsumer)}
- * method.
- *
- * @see ChannelPipelineFactory
- */
-public abstract class ServerPipelineFactory extends ChannelInitializer<Channel> {
-
-    /**
-     * Creates a new {@link ServerPipelineFactory} using the given {@link NettyConsumer}
-     *
-     * @param consumer the associated consumer
-     * @return the {@link ServerPipelineFactory} associated to the given consumer.
-     */
-    public abstract ServerPipelineFactory createPipelineFactory(NettyConsumer consumer);
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactoryAsynchTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactoryAsynchTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactoryAsynchTest.java
index df7f49d..d920699 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactoryAsynchTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactoryAsynchTest.java
@@ -70,7 +70,7 @@ public class NettyCustomPipelineFactoryAsynchTest extends BaseNettyTest {
         assertEquals(true, serverInvoked);
     }
 
-    public class TestClientChannelPipelineFactory extends ClientPipelineFactory {
+    public class TestClientChannelPipelineFactory extends ClientInitializerFactory {
         private int maxLineSize = 1024;
         private NettyProducer producer;
 
@@ -90,12 +90,12 @@ public class NettyCustomPipelineFactoryAsynchTest extends BaseNettyTest {
         }
 
         @Override
-        public ClientPipelineFactory createPipelineFactory(NettyProducer producer) {
+        public ClientInitializerFactory createPipelineFactory(NettyProducer producer) {
             return new TestClientChannelPipelineFactory(producer);
         }
     }
 
-    public class TestServerChannelPipelineFactory extends ServerPipelineFactory {
+    public class TestServerChannelPipelineFactory extends ServerInitializerFactory {
         private int maxLineSize = 1024;
         private NettyConsumer consumer;
 
@@ -113,7 +113,7 @@ public class NettyCustomPipelineFactoryAsynchTest extends BaseNettyTest {
         }
 
         @Override
-        public ServerPipelineFactory createPipelineFactory(NettyConsumer consumer) {
+        public ServerInitializerFactory createPipelineFactory(NettyConsumer consumer) {
             return new TestServerChannelPipelineFactory(consumer);
         }
     }

http://git-wip-us.apache.org/repos/asf/camel/blob/00b64c8a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactorySynchTest.java
----------------------------------------------------------------------
diff --git a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactorySynchTest.java b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactorySynchTest.java
index ebfa262..19be9c2 100644
--- a/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactorySynchTest.java
+++ b/components/camel-netty4/src/test/java/org/apache/camel/component/netty4/NettyCustomPipelineFactorySynchTest.java
@@ -70,7 +70,7 @@ public class NettyCustomPipelineFactorySynchTest extends BaseNettyTest {
         assertEquals(true, serverInvoked);
     }
 
-    public class TestClientChannelPipelineFactory extends ClientPipelineFactory {
+    public class TestClientChannelPipelineFactory extends ClientInitializerFactory {
         private int maxLineSize = 1024;
         private NettyProducer producer;
 
@@ -91,12 +91,12 @@ public class NettyCustomPipelineFactorySynchTest extends BaseNettyTest {
         }
 
         @Override
-        public ClientPipelineFactory createPipelineFactory(NettyProducer producer) {
+        public ClientInitializerFactory createPipelineFactory(NettyProducer producer) {
             return new TestClientChannelPipelineFactory(producer);
         }
     }
 
-    public class TestServerChannelPipelineFactory extends ServerPipelineFactory {
+    public class TestServerChannelPipelineFactory extends ServerInitializerFactory {
         private int maxLineSize = 1024;
         private NettyConsumer consumer;
 
@@ -116,7 +116,7 @@ public class NettyCustomPipelineFactorySynchTest extends BaseNettyTest {
         }
 
         @Override
-        public ServerPipelineFactory createPipelineFactory(NettyConsumer consumer) {
+        public ServerInitializerFactory createPipelineFactory(NettyConsumer consumer) {
             return new TestServerChannelPipelineFactory(consumer);
         }
     }


[2/2] git commit: Rename *PiplelineFactory to *InitializerFactory

Posted by ni...@apache.org.
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 <wi...@gmail.com>
Authored: Sun Sep 7 17:28:02 2014 +0800
Committer: Willem Jiang <wi...@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);
+    }
+
+}