Updated Branches:
  refs/heads/master 90c679c6f -> b20999969

CAMEL-6327: More work on new camel-netty-http component.


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

Branch: refs/heads/master
Commit: b209999692869737ce60b8ea2a006d6d30f16954
Parents: 90c679c
Author: Claus Ibsen <davscl...@apache.org>
Authored: Wed Jun 19 10:50:38 2013 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Wed Jun 19 10:58:56 2013 +0200

----------------------------------------------------------------------
 .../component/netty/NettyConfiguration.java     | 245 +---------------
 .../camel/component/netty/NettyConsumer.java    |   1 +
 .../NettyServerBootstrapConfiguration.java      | 276 +++++++++++++++++++
 .../SingleTCPNettyServerBootstrapFactory.java   |   8 +-
 4 files changed, 283 insertions(+), 247 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/b2099996/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
index 919e609..7ebefdc 100644
--- 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
+++ 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConfiguration.java
@@ -37,39 +37,18 @@ import org.jboss.netty.util.CharsetUtil;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-public class NettyConfiguration implements Cloneable {
+public class NettyConfiguration extends NettyServerBootstrapConfiguration 
implements Cloneable {
     private static final Logger LOG = 
LoggerFactory.getLogger(NettyConfiguration.class);
 
-    private String protocol;
-    private String host;
-    private int port;
-    private boolean keepAlive = true;
-    private boolean tcpNoDelay = true;
-    private boolean broadcast;
-    private long connectTimeout = 10000;
     private long requestTimeout;
-    private boolean reuseAddress = true;
     private boolean sync = true;
     private boolean textline;
     private TextLineDelimiter delimiter = TextLineDelimiter.LINE;
     private boolean autoAppendDelimiter = true;
     private int decoderMaxLineLength = 1024;
     private String encoding;
-    private String passphrase;
-    private File keyStoreFile;
-    private File trustStoreFile;
-    private String keyStoreResource;
-    private String trustStoreResource;
-    private SslHandler sslHandler;
     private List<ChannelHandler> encoders = new ArrayList<ChannelHandler>();
     private List<ChannelHandler> decoders = new ArrayList<ChannelHandler>();
-    private boolean ssl;
-    private long sendBufferSize = 65536;
-    private long receiveBufferSize = 65536;
-    private int receiveBufferSizePredictor;
-    private int workerCount;
-    private String keyStoreFormat;
-    private String securityProvider;
     private boolean disconnect;
     private boolean lazyChannelCreation = true;
     private boolean transferExchange;
@@ -79,9 +58,7 @@ public class NettyConfiguration implements Cloneable {
     private LoggingLevel serverClosedChannelExceptionCaughtLogLevel = 
LoggingLevel.DEBUG;
     private boolean allowDefaultCodec = true;
     private ClientPipelineFactory clientPipelineFactory;
-    private ServerPipelineFactory serverPipelineFactory;
     private SSLContextParameters sslContextParameters;
-    private boolean needClientAuth;
     private int maximumPoolSize = 16;
     private boolean orderedThreadPoolExecutor = true;
     private int producerPoolMaxActive = -1;
@@ -89,8 +66,6 @@ public class NettyConfiguration implements Cloneable {
     private int producerPoolMaxIdle = 100;
     private long producerPoolMinEvictableIdle = 5 * 60 * 1000L;
     private boolean producerPoolEnabled = true;
-    private int backlog;
-    private Map<String, Object> options;
 
     /**
      * Returns a copy of this configuration
@@ -226,66 +201,6 @@ public class NettyConfiguration implements Cloneable {
         return Charset.forName(encoding).name();
     }
 
-    public boolean isTcp() {
-        return protocol.equalsIgnoreCase("tcp");
-    }
-
-    public String getProtocol() {
-        return protocol;
-    }
-
-    public void setProtocol(String protocol) {
-        this.protocol = protocol;
-    }
-
-    public String getHost() {
-        return host;
-    }
-
-    public void setHost(String host) {
-        this.host = host;
-    }
-
-    public int getPort() {
-        return port;
-    }
-
-    public void setPort(int port) {
-        this.port = port;
-    }
-
-    public boolean isKeepAlive() {
-        return keepAlive;
-    }
-
-    public void setKeepAlive(boolean keepAlive) {
-        this.keepAlive = keepAlive;
-    }
-
-    public boolean isTcpNoDelay() {
-        return tcpNoDelay;
-    }
-
-    public void setTcpNoDelay(boolean tcpNoDelay) {
-        this.tcpNoDelay = tcpNoDelay;
-    }
-
-    public boolean isBroadcast() {
-        return broadcast;
-    }
-
-    public void setBroadcast(boolean broadcast) {
-        this.broadcast = broadcast;
-    }
-
-    public long getConnectTimeout() {
-        return connectTimeout;
-    }
-
-    public void setConnectTimeout(long connectTimeout) {
-        this.connectTimeout = connectTimeout;
-    }
-
     public long getRequestTimeout() {
         return requestTimeout;
     }
@@ -294,14 +209,6 @@ public class NettyConfiguration implements Cloneable {
         this.requestTimeout = requestTimeout;
     }
 
-    public boolean isReuseAddress() {
-        return reuseAddress;
-    }
-
-    public void setReuseAddress(boolean reuseAddress) {
-        this.reuseAddress = reuseAddress;
-    }
-
     public boolean isSync() {
         return sync;
     }
@@ -350,14 +257,6 @@ public class NettyConfiguration implements Cloneable {
         this.encoding = encoding;
     }
 
-    public SslHandler getSslHandler() {
-        return sslHandler;
-    }
-
-    public void setSslHandler(SslHandler sslHandler) {
-        this.sslHandler = sslHandler;
-    }
-
     public List<ChannelHandler> getDecoders() {
         return decoders;
     }
@@ -394,106 +293,6 @@ public class NettyConfiguration implements Cloneable {
         }
     }
 
-    public long getSendBufferSize() {
-        return sendBufferSize;
-    }
-
-    public void setSendBufferSize(long sendBufferSize) {
-        this.sendBufferSize = sendBufferSize;
-    }
-
-    public boolean isSsl() {
-        return ssl;
-    }
-
-    public void setSsl(boolean ssl) {
-        this.ssl = ssl;
-    }
-
-    public boolean isNeedClientAuth() {
-        return needClientAuth;
-    }
-
-    public void setNeedClientAuth(boolean needClientAuth) {
-        this.needClientAuth = needClientAuth;
-    }
-
-    public long getReceiveBufferSize() {
-        return receiveBufferSize;
-    }
-
-    public void setReceiveBufferSize(long receiveBufferSize) {
-        this.receiveBufferSize = receiveBufferSize;
-    }
-    
-    public int getReceiveBufferSizePredictor() {
-        return receiveBufferSizePredictor;
-    }
-
-    public void setReceiveBufferSizePredictor(int receiveBufferSizePredictor) {
-        this.receiveBufferSizePredictor = receiveBufferSizePredictor;
-    }
-
-    public String getPassphrase() {
-        return passphrase;
-    }
-
-    public void setPassphrase(String passphrase) {
-        this.passphrase = passphrase;
-    }
-
-    @Deprecated
-    public File getKeyStoreFile() {
-        return keyStoreFile;
-    }
-
-    @Deprecated
-    public void setKeyStoreFile(File keyStoreFile) {
-        this.keyStoreFile = keyStoreFile;
-    }
-
-    @Deprecated
-    public File getTrustStoreFile() {
-        return trustStoreFile;
-    }
-
-    @Deprecated
-    public void setTrustStoreFile(File trustStoreFile) {
-        this.trustStoreFile = trustStoreFile;
-    }
-
-    public String getKeyStoreResource() {
-        return keyStoreResource;
-    }
-
-    public void setKeyStoreResource(String keyStoreResource) {
-        this.keyStoreResource = keyStoreResource;
-    }
-
-    public String getTrustStoreResource() {
-        return trustStoreResource;
-    }
-
-    public void setTrustStoreResource(String trustStoreResource) {
-        this.trustStoreResource = trustStoreResource;
-    }
-
-    public String getKeyStoreFormat() {
-        return keyStoreFormat;
-    }
-
-    public void setKeyStoreFormat(String keyStoreFormat) {
-        this.keyStoreFormat = keyStoreFormat;
-    }
-
-    public String getSecurityProvider() {
-        return securityProvider;
-    }
-
-    public void setSecurityProvider(String securityProvider) {
-        this.securityProvider = securityProvider;
-    }
-
     public boolean isDisconnect() {
         return disconnect;
     }
@@ -558,10 +357,6 @@ public class NettyConfiguration implements Cloneable {
         this.allowDefaultCodec = allowDefaultCodec;
     }
 
-    public String getAddress() {
-        return host + ":" + port;
-    }
-
     public void setClientPipelineFactory(ClientPipelineFactory 
clientPipelineFactory) {
         this.clientPipelineFactory = clientPipelineFactory;
     }
@@ -570,22 +365,6 @@ public class NettyConfiguration implements Cloneable {
         return clientPipelineFactory;
     }
 
-    public void setServerPipelineFactory(ServerPipelineFactory 
serverPipelineFactory) {
-        this.serverPipelineFactory = serverPipelineFactory;
-    }
-
-    public ServerPipelineFactory getServerPipelineFactory() {
-        return serverPipelineFactory;
-    }
-
-    public int getWorkerCount() {
-        return workerCount;
-    }
-
-    public void setWorkerCount(int workerCount) {
-        this.workerCount = workerCount;
-    }
-
     public SSLContextParameters getSslContextParameters() {
         return sslContextParameters;
     }
@@ -650,29 +429,9 @@ public class NettyConfiguration implements Cloneable {
         this.producerPoolEnabled = producerPoolEnabled;
     }
 
-    public int getBacklog() {
-        return backlog;
-    }
-
-    public void setBacklog(int backlog) {
-        this.backlog = backlog;
-    }
-
-    public Map<String, Object> getOptions() {
-        return options;
-    }
-
-    /**
-     * Additional options to set on Netty.
-     */
-    public void setOptions(Map<String, Object> options) {
-        this.options = options;
-    }
-
     private static <T> void addToHandlersList(List<T> configured, List<T> 
handlers, Class<T> handlerType) {
         if (handlers != null) {
-            for (int x = 0; x < handlers.size(); x++) {
-                T handler = handlers.get(x);
+            for (T handler : handlers) {
                 if (handlerType.isInstance(handler)) {
                     configured.add(handler);
                 }

http://git-wip-us.apache.org/repos/asf/camel/blob/b2099996/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConsumer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConsumer.java
 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConsumer.java
index 6435b40..938ef96 100644
--- 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConsumer.java
+++ 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyConsumer.java
@@ -33,6 +33,7 @@ public class NettyConsumer extends DefaultConsumer {
         super(nettyEndpoint, processor);
         this.context = this.getEndpoint().getCamelContext();
         this.configuration = configuration;
+        
setNettyServerBootstrapFactory(configuration.getNettyServerBootstrapFactory());
         setExceptionHandler(new NettyConsumerExceptionHandler(this));
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/b2099996/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBootstrapConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBootstrapConfiguration.java
 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBootstrapConfiguration.java
new file mode 100644
index 0000000..cbcfcae
--- /dev/null
+++ 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/NettyServerBootstrapConfiguration.java
@@ -0,0 +1,276 @@
+/**
+ * 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.netty;
+
+import java.io.File;
+import java.util.Map;
+
+import org.jboss.netty.handler.ssl.SslHandler;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NettyServerBootstrapConfiguration implements Cloneable {
+    private static final Logger LOG = 
LoggerFactory.getLogger(NettyServerBootstrapConfiguration.class);
+
+    protected String protocol;
+    protected String host;
+    protected int port;
+    protected boolean broadcast;
+    protected long sendBufferSize = 65536;
+    protected long receiveBufferSize = 65536;
+    protected int receiveBufferSizePredictor;
+    protected int workerCount;
+    protected boolean keepAlive = true;
+    protected boolean tcpNoDelay = true;
+    protected boolean reuseAddress = true;
+    protected long connectTimeout = 10000;
+    protected int backlog;
+    protected ServerPipelineFactory 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
+    protected boolean ssl;
+    protected SslHandler sslHandler;
+    protected boolean needClientAuth;
+    protected File keyStoreFile;
+    protected File trustStoreFile;
+    protected String keyStoreResource;
+    protected String trustStoreResource;
+    protected String keyStoreFormat;
+    protected String securityProvider;
+    protected String passphrase;
+
+    public String getAddress() {
+        return host + ":" + port;
+    }
+
+    public boolean isTcp() {
+        return protocol.equalsIgnoreCase("tcp");
+    }
+
+    public String getProtocol() {
+        return protocol;
+    }
+
+    public void setProtocol(String protocol) {
+        this.protocol = protocol;
+    }
+
+    public String getHost() {
+        return host;
+    }
+
+    public void setHost(String host) {
+        this.host = host;
+    }
+
+    public int getPort() {
+        return port;
+    }
+
+    public void setPort(int port) {
+        this.port = port;
+    }
+
+    public boolean isBroadcast() {
+        return broadcast;
+    }
+
+    public void setBroadcast(boolean broadcast) {
+        this.broadcast = broadcast;
+    }
+
+    public long getSendBufferSize() {
+        return sendBufferSize;
+    }
+
+    public void setSendBufferSize(long sendBufferSize) {
+        this.sendBufferSize = sendBufferSize;
+    }
+
+    public long getReceiveBufferSize() {
+        return receiveBufferSize;
+    }
+
+    public void setReceiveBufferSize(long receiveBufferSize) {
+        this.receiveBufferSize = receiveBufferSize;
+    }
+
+    public int getReceiveBufferSizePredictor() {
+        return receiveBufferSizePredictor;
+    }
+
+    public void setReceiveBufferSizePredictor(int receiveBufferSizePredictor) {
+        this.receiveBufferSizePredictor = receiveBufferSizePredictor;
+    }
+
+    public int getWorkerCount() {
+        return workerCount;
+    }
+
+    public void setWorkerCount(int workerCount) {
+        this.workerCount = workerCount;
+    }
+
+    public boolean isKeepAlive() {
+        return keepAlive;
+    }
+
+    public void setKeepAlive(boolean keepAlive) {
+        this.keepAlive = keepAlive;
+    }
+
+    public boolean isTcpNoDelay() {
+        return tcpNoDelay;
+    }
+
+    public void setTcpNoDelay(boolean tcpNoDelay) {
+        this.tcpNoDelay = tcpNoDelay;
+    }
+
+    public boolean isReuseAddress() {
+        return reuseAddress;
+    }
+
+    public void setReuseAddress(boolean reuseAddress) {
+        this.reuseAddress = reuseAddress;
+    }
+
+    public long getConnectTimeout() {
+        return connectTimeout;
+    }
+
+    public void setConnectTimeout(long connectTimeout) {
+        this.connectTimeout = connectTimeout;
+    }
+
+    public int getBacklog() {
+        return backlog;
+    }
+
+    public void setBacklog(int backlog) {
+        this.backlog = backlog;
+    }
+
+    public boolean isSsl() {
+        return ssl;
+    }
+
+    public void setSsl(boolean ssl) {
+        this.ssl = ssl;
+    }
+
+    public SslHandler getSslHandler() {
+        return sslHandler;
+    }
+
+    public void setSslHandler(SslHandler sslHandler) {
+        this.sslHandler = sslHandler;
+    }
+
+    public boolean isNeedClientAuth() {
+        return needClientAuth;
+    }
+
+    public void setNeedClientAuth(boolean needClientAuth) {
+        this.needClientAuth = needClientAuth;
+    }
+
+    @Deprecated
+    public File getKeyStoreFile() {
+        return keyStoreFile;
+    }
+
+    @Deprecated
+    public void setKeyStoreFile(File keyStoreFile) {
+        this.keyStoreFile = keyStoreFile;
+    }
+
+    @Deprecated
+    public File getTrustStoreFile() {
+        return trustStoreFile;
+    }
+
+    @Deprecated
+    public void setTrustStoreFile(File trustStoreFile) {
+        this.trustStoreFile = trustStoreFile;
+    }
+
+    public String getKeyStoreResource() {
+        return keyStoreResource;
+    }
+
+    public void setKeyStoreResource(String keyStoreResource) {
+        this.keyStoreResource = keyStoreResource;
+    }
+
+    public String getTrustStoreResource() {
+        return trustStoreResource;
+    }
+
+    public void setTrustStoreResource(String trustStoreResource) {
+        this.trustStoreResource = trustStoreResource;
+    }
+
+    public String getKeyStoreFormat() {
+        return keyStoreFormat;
+    }
+
+    public void setKeyStoreFormat(String keyStoreFormat) {
+        this.keyStoreFormat = keyStoreFormat;
+    }
+
+    public String getSecurityProvider() {
+        return securityProvider;
+    }
+
+    public void setSecurityProvider(String securityProvider) {
+        this.securityProvider = securityProvider;
+    }
+
+    public String getPassphrase() {
+        return passphrase;
+    }
+
+    public void setPassphrase(String passphrase) {
+        this.passphrase = passphrase;
+    }
+
+    public ServerPipelineFactory getServerPipelineFactory() {
+        return serverPipelineFactory;
+    }
+
+    public void setServerPipelineFactory(ServerPipelineFactory 
serverPipelineFactory) {
+        this.serverPipelineFactory = serverPipelineFactory;
+    }
+
+    public NettyServerBootstrapFactory getNettyServerBootstrapFactory() {
+        return nettyServerBootstrapFactory;
+    }
+
+    public void setNettyServerBootstrapFactory(NettyServerBootstrapFactory 
nettyServerBootstrapFactory) {
+        this.nettyServerBootstrapFactory = nettyServerBootstrapFactory;
+    }
+
+    public Map<String, Object> getOptions() {
+        return options;
+    }
+
+    public void setOptions(Map<String, Object> options) {
+        this.options = options;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/b2099996/components/camel-netty/src/main/java/org/apache/camel/component/netty/SingleTCPNettyServerBootstrapFactory.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/SingleTCPNettyServerBootstrapFactory.java
 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/SingleTCPNettyServerBootstrapFactory.java
index 22b2d49..c6dba03 100644
--- 
a/components/camel-netty/src/main/java/org/apache/camel/component/netty/SingleTCPNettyServerBootstrapFactory.java
+++ 
b/components/camel-netty/src/main/java/org/apache/camel/component/netty/SingleTCPNettyServerBootstrapFactory.java
@@ -79,15 +79,15 @@ public class SingleTCPNettyServerBootstrapFactory extends 
ServiceSupport impleme
     @Override
     protected void doStart() throws Exception {
         ObjectHelper.notNull(camelContext, "CamelContext");
-        startServerBoostrap();
+        startServerBootstrap();
     }
 
     @Override
     protected void doStop() throws Exception {
-        stopServerBoostrap();
+        stopServerBootstrap();
     }
 
-    protected void startServerBoostrap() {
+    protected void startServerBootstrap() {
         bossExecutor = 
camelContext.getExecutorServiceManager().newCachedThreadPool(this, 
"NettyTCPBoss");
         workerExecutor = 
camelContext.getExecutorServiceManager().newCachedThreadPool(this, 
"NettyTCPWorker");
 
@@ -124,7 +124,7 @@ public class SingleTCPNettyServerBootstrapFactory extends 
ServiceSupport impleme
         allChannels.add(channel);
     }
 
-    protected void stopServerBoostrap() {
+    protected void stopServerBootstrap() {
         // close all channels
         LOG.trace("Closing {} channels", allChannels.size());
         ChannelGroupFuture future = allChannels.close();

Reply via email to