Updated Branches:
  refs/heads/master 17eabf535 -> b60b6cc4f

CAMEL-6488: camel-netty-http allow to share port in OSGi environment. Work in 
progress.


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

Branch: refs/heads/master
Commit: 97a91a04275304f27ec8da460d9aa7a5731bb4d2
Parents: 17eabf5
Author: Claus Ibsen <davscl...@apache.org>
Authored: Wed Jun 26 10:29:27 2013 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Wed Jun 26 10:29:27 2013 +0200

----------------------------------------------------------------------
 .../http/DefaultNettySharedHttpServer.java      |  6 +--
 .../http/HttpServerSharedPipelineFactory.java   | 18 ++-------
 .../netty/http/NettySharedHttpServer.java       |  4 +-
 ...ySharedHttpServerBootstrapConfiguration.java | 41 ++++++++++++++++++++
 .../netty/http/NettySharedHttpServerTest.java   |  3 +-
 5 files changed, 52 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/97a91a04/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettySharedHttpServer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettySharedHttpServer.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettySharedHttpServer.java
index eae6669..0ef3c2a 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettySharedHttpServer.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/DefaultNettySharedHttpServer.java
@@ -34,12 +34,12 @@ public class DefaultNettySharedHttpServer extends 
ServiceSupport implements Nett
 
     private static final Logger LOG = 
LoggerFactory.getLogger(DefaultNettySharedHttpServer.class);
 
-    private NettyServerBootstrapConfiguration configuration;
+    private NettySharedHttpServerBootstrapConfiguration configuration;
     private HttpServerConsumerChannelFactory channelFactory;
     private HttpServerBootstrapFactory bootstrapFactory;
     private ClassResolver classResolver;
 
-    public void 
setNettyServerBootstrapConfiguration(NettyServerBootstrapConfiguration 
configuration) {
+    public void 
setNettyServerBootstrapConfiguration(NettySharedHttpServerBootstrapConfiguration
 configuration) {
         this.configuration = configuration;
     }
 
@@ -64,7 +64,7 @@ public class DefaultNettySharedHttpServer extends 
ServiceSupport implements Nett
 
         // port must be set
         if (configuration.getPort() <= 0) {
-            throw new IllegalArgumentException("Port must be configured on 
NettyServerBootstrapConfiguration " + configuration);
+            throw new IllegalArgumentException("Port must be configured on 
NettySharedHttpServerBootstrapConfiguration " + configuration);
         }
 
         LOG.info("Starting NettySharedHttpServer using configuration: {} on 
port: {}", configuration, configuration.getPort());

http://git-wip-us.apache.org/repos/asf/camel/blob/97a91a04/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
index d82143d..7200f8e 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerSharedPipelineFactory.java
@@ -43,12 +43,12 @@ import org.slf4j.LoggerFactory;
 public class HttpServerSharedPipelineFactory extends HttpServerPipelineFactory 
{
 
     private static final Logger LOG = 
LoggerFactory.getLogger(HttpServerSharedPipelineFactory.class);
-    private final NettyServerBootstrapConfiguration configuration;
+    private final NettySharedHttpServerBootstrapConfiguration configuration;
     private final HttpServerConsumerChannelFactory channelFactory;
     private final ClassResolver classResolver;
     private SSLContext sslContext;
 
-    public HttpServerSharedPipelineFactory(NettyServerBootstrapConfiguration 
configuration, HttpServerConsumerChannelFactory channelFactory,
+    public 
HttpServerSharedPipelineFactory(NettySharedHttpServerBootstrapConfiguration 
configuration, HttpServerConsumerChannelFactory channelFactory,
                                            ClassResolver classResolver) {
         this.configuration = configuration;
         this.channelFactory = channelFactory;
@@ -82,11 +82,11 @@ public class HttpServerSharedPipelineFactory extends 
HttpServerPipelineFactory {
 
         pipeline.addLast("decoder", new HttpRequestDecoder());
         // Uncomment the following line if you don't want to handle HttpChunks.
-        if (supportChunked()) {
+        if (configuration.isChunked()) {
             pipeline.addLast("aggregator", new HttpChunkAggregator(1048576));
         }
         pipeline.addLast("encoder", new HttpResponseEncoder());
-        if (supportCompressed()) {
+        if (configuration.isCompression()) {
             pipeline.addLast("deflater", new HttpContentCompressor());
         }
 
@@ -153,14 +153,4 @@ public class HttpServerSharedPipelineFactory extends 
HttpServerPipelineFactory {
         }
     }
 
-    private boolean supportChunked() {
-        // TODO: options on bootstrap
-        return true;
-    }
-
-    private boolean supportCompressed() {
-        // TODO: options on bootstrap
-        return false;
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/97a91a04/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServer.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServer.java
index 8e41d40..c29e553 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServer.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServer.java
@@ -26,7 +26,7 @@ import org.apache.camel.spi.ClassResolver;
  * to be re-used among other Camel applications.
  * <p/>
  * To use this, just define a {@link NettyServerBootstrapConfiguration} 
configuration, and
- * set this using {@link 
#setNettyServerBootstrapConfiguration(org.apache.camel.component.netty.NettyServerBootstrapConfiguration)}.
+ * set this using {@link 
#setNettyServerBootstrapConfiguration(NettySharedHttpServerBootstrapConfiguration)}.
  * Then call the {@link #start()} to initialize this shared server.
  */
 public interface NettySharedHttpServer extends Service {
@@ -34,7 +34,7 @@ public interface NettySharedHttpServer extends Service {
     /**
      * Sets the bootstrap configuration to use by this shared Netty HTTP 
server.
      */
-    void 
setNettyServerBootstrapConfiguration(NettyServerBootstrapConfiguration 
configuration);
+    void 
setNettyServerBootstrapConfiguration(NettySharedHttpServerBootstrapConfiguration
 configuration);
 
     /**
      * To use a custom {@link ClassResolver} for loading resource on the 
classpath.

http://git-wip-us.apache.org/repos/asf/camel/blob/97a91a04/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
new file mode 100644
index 0000000..0e99996
--- /dev/null
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettySharedHttpServerBootstrapConfiguration.java
@@ -0,0 +1,41 @@
+/**
+ * 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.http;
+
+import org.apache.camel.component.netty.NettyServerBootstrapConfiguration;
+
+public class NettySharedHttpServerBootstrapConfiguration extends 
NettyServerBootstrapConfiguration {
+
+    private boolean chunked = true;
+    private boolean compression;
+
+    public boolean isChunked() {
+        return chunked;
+    }
+
+    public void setChunked(boolean chunked) {
+        this.chunked = chunked;
+    }
+
+    public boolean isCompression() {
+        return compression;
+    }
+
+    public void setCompression(boolean compression) {
+        this.compression = compression;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/97a91a04/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettySharedHttpServerTest.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettySharedHttpServerTest.java
 
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettySharedHttpServerTest.java
index ca887ca..aa8073f 100644
--- 
a/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettySharedHttpServerTest.java
+++ 
b/components/camel-netty-http/src/test/java/org/apache/camel/component/netty/http/NettySharedHttpServerTest.java
@@ -29,11 +29,12 @@ public class NettySharedHttpServerTest extends 
BaseNettyTest {
     protected JndiRegistry createRegistry() throws Exception {
         nettySharedHttpServer = new DefaultNettySharedHttpServer();
 
-        NettyServerBootstrapConfiguration configuration = new 
NettyServerBootstrapConfiguration();
+        NettySharedHttpServerBootstrapConfiguration configuration = new 
NettySharedHttpServerBootstrapConfiguration();
         configuration.setPort(getPort());
         configuration.setHost("localhost");
         configuration.setBacklog(20);
         configuration.setKeepAlive(true);
+        configuration.setCompression(true);
         
nettySharedHttpServer.setNettyServerBootstrapConfiguration(configuration);
 
         nettySharedHttpServer.start();

Reply via email to