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/aac94287
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/aac94287
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/aac94287

Branch: refs/heads/master
Commit: aac942878b5b54f9a25941c1d83c22059855beec
Parents: 2e27843
Author: Claus Ibsen <davscl...@apache.org>
Authored: Tue Jun 18 12:24:01 2013 +0200
Committer: Claus Ibsen <davscl...@apache.org>
Committed: Tue Jun 18 12:25:24 2013 +0200

----------------------------------------------------------------------
 .../http/HttpNettyServerBootstrapFactory.java   | 60 ---------------
 .../netty/http/HttpServerBootstrapFactory.java  | 81 ++++++++++++++++++++
 .../netty/http/NettyHttpComponent.java          |  8 +-
 .../component/netty/http/NettyHttpConsumer.java |  2 +-
 .../component/netty/http/NettyHttpEndpoint.java |  2 +-
 .../http/handlers/HttpServerChannelHandler.java |  5 +-
 .../HttpServerMultiplexChannelHandler.java      |  5 +-
 .../src/test/resources/log4j.properties         |  1 +
 8 files changed, 90 insertions(+), 74 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/aac94287/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpNettyServerBootstrapFactory.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpNettyServerBootstrapFactory.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpNettyServerBootstrapFactory.java
deleted file mode 100644
index 3bcc7ab..0000000
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpNettyServerBootstrapFactory.java
+++ /dev/null
@@ -1,60 +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.netty.http;
-
-import org.apache.camel.CamelContext;
-import org.apache.camel.component.netty.NettyConfiguration;
-import org.apache.camel.component.netty.NettyConsumer;
-import org.apache.camel.component.netty.SingleTCPNettyServerBootstrapFactory;
-import org.jboss.netty.channel.ChannelPipelineFactory;
-
-public class HttpNettyServerBootstrapFactory extends 
SingleTCPNettyServerBootstrapFactory {
-
-    private final NettyHttpComponent component;
-    private int port;
-
-    public HttpNettyServerBootstrapFactory(NettyHttpComponent component) {
-        this.component = component;
-    }
-
-    @Override
-    public void init(CamelContext camelContext, NettyConfiguration 
configuration, ChannelPipelineFactory pipelineFactory) {
-        super.init(camelContext, configuration, pipelineFactory);
-        this.port = configuration.getPort();
-    }
-
-    public void addConsumer(NettyConsumer consumer) {
-        
component.getMultiplexChannelHandler(port).addConsumer((NettyHttpConsumer) 
consumer);
-    }
-
-    @Override
-    public void removeConsumer(NettyConsumer consumer) {
-        
component.getMultiplexChannelHandler(port).removeConsumer((NettyHttpConsumer) 
consumer);
-    }
-
-    @Override
-    public void stop() throws Exception {
-        // only stop if no more active consumers
-        int consumers = component.getMultiplexChannelHandler(port).consumers();
-        if (consumers == 0) {
-            super.stop();
-        } else {
-            LOG.info("There are {} active consumers, so cannot stop {} yet.", 
consumers, HttpNettyServerBootstrapFactory.class.getName());
-        }
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/camel/blob/aac94287/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerBootstrapFactory.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerBootstrapFactory.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerBootstrapFactory.java
new file mode 100644
index 0000000..d004d96
--- /dev/null
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/HttpServerBootstrapFactory.java
@@ -0,0 +1,81 @@
+/**
+ * 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.CamelContext;
+import org.apache.camel.component.netty.NettyConfiguration;
+import org.apache.camel.component.netty.NettyConsumer;
+import org.apache.camel.component.netty.SingleTCPNettyServerBootstrapFactory;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class HttpServerBootstrapFactory extends 
SingleTCPNettyServerBootstrapFactory {
+
+    private static final Logger LOG = 
LoggerFactory.getLogger(HttpServerBootstrapFactory.class);
+    private final NettyHttpComponent component;
+    private int port;
+
+    public HttpServerBootstrapFactory(NettyHttpComponent component) {
+        this.component = component;
+    }
+
+    @Override
+    public void init(CamelContext camelContext, NettyConfiguration 
configuration, ChannelPipelineFactory pipelineFactory) {
+        super.init(camelContext, configuration, pipelineFactory);
+        this.port = configuration.getPort();
+
+        LOG.info("BootstrapFactory on port {} is using configuration: {}", 
port, configuration);
+    }
+
+    public void addConsumer(NettyConsumer consumer) {
+        if (LOG.isDebugEnabled()) {
+            NettyHttpConsumer httpConsumer = (NettyHttpConsumer) consumer;
+            LOG.debug("BootstrapFactory on port {} is adding consumer with 
context-path {}", port, httpConsumer.getConfiguration().getPath());
+        }
+        
component.getMultiplexChannelHandler(port).addConsumer((NettyHttpConsumer) 
consumer);
+    }
+
+    @Override
+    public void removeConsumer(NettyConsumer consumer) {
+        if (LOG.isDebugEnabled()) {
+            NettyHttpConsumer httpConsumer = (NettyHttpConsumer) consumer;
+            LOG.debug("BootstrapFactory on port {} is removing consumer with 
context-path {}", port, httpConsumer.getConfiguration().getPath());
+        }
+        
component.getMultiplexChannelHandler(port).removeConsumer((NettyHttpConsumer) 
consumer);
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        LOG.debug("BootstrapFactory on port {} is starting", port);
+        super.doStart();
+    }
+
+    @Override
+    public void stop() throws Exception {
+        // only stop if no more active consumers
+        int consumers = component.getMultiplexChannelHandler(port).consumers();
+        if (consumers == 0) {
+            LOG.debug("BootstrapFactory on port {} is stopping", port);
+            super.stop();
+        } else {
+            LOG.debug("BootstrapFactory on port {} has {} active consumers, so 
cannot stop {} yet.",
+                    new Object[]{port, consumers, 
HttpServerBootstrapFactory.class.getName()});
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/aac94287/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
index 4c775ae..8dfe774 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpComponent.java
@@ -41,7 +41,7 @@ public class NettyHttpComponent extends NettyComponent 
implements HeaderFilterSt
     // - urlrewrite
 
     private final Map<Integer, HttpServerMultiplexChannelHandler> 
multiplexChannelHandlers = new HashMap<Integer, 
HttpServerMultiplexChannelHandler>();
-    private final Map<String, HttpNettyServerBootstrapFactory> 
bootstrapFactories = new HashMap<String, HttpNettyServerBootstrapFactory>();
+    private final Map<String, HttpServerBootstrapFactory> bootstrapFactories = 
new HashMap<String, HttpServerBootstrapFactory>();
     private NettyHttpBinding nettyHttpBinding;
     private HeaderFilterStrategy headerFilterStrategy;
 
@@ -127,11 +127,11 @@ public class NettyHttpComponent extends NettyComponent 
implements HeaderFilterSt
         return answer;
     }
 
-    protected synchronized HttpNettyServerBootstrapFactory 
getOrCreateHttpNettyServerBootstrapFactory(NettyHttpConsumer consumer) {
+    protected synchronized HttpServerBootstrapFactory 
getOrCreateHttpNettyServerBootstrapFactory(NettyHttpConsumer consumer) {
         String key = consumer.getConfiguration().getAddress();
-        HttpNettyServerBootstrapFactory answer = bootstrapFactories.get(key);
+        HttpServerBootstrapFactory answer = bootstrapFactories.get(key);
         if (answer == null) {
-            answer = new HttpNettyServerBootstrapFactory(this);
+            answer = new HttpServerBootstrapFactory(this);
             answer.init(getCamelContext(), consumer.getConfiguration(), new 
HttpServerPipelineFactory(consumer));
             bootstrapFactories.put(key, answer);
         }

http://git-wip-us.apache.org/repos/asf/camel/blob/aac94287/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConsumer.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConsumer.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConsumer.java
index 8c60595..2c27204 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConsumer.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpConsumer.java
@@ -43,7 +43,7 @@ public class NettyHttpConsumer extends NettyConsumer {
     @Override
     protected void doStart() throws Exception {
         super.doStart();
-        ObjectHelper.notNull(getNettyServerBootstrapFactory(), 
"HttpNettyServerBootstrapFactory", this);
+        ObjectHelper.notNull(getNettyServerBootstrapFactory(), 
"HttpServerBootstrapFactory", this);
         getNettyServerBootstrapFactory().addConsumer(this);
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/aac94287/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpEndpoint.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpEndpoint.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpEndpoint.java
index 2c9399f..011ce65 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpEndpoint.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/NettyHttpEndpoint.java
@@ -57,7 +57,7 @@ public class NettyHttpEndpoint extends NettyEndpoint 
implements HeaderFilterStra
         NettyHttpConsumer answer = new NettyHttpConsumer(this, processor, 
getConfiguration());
         configureConsumer(answer);
         // reuse pipeline factory for the same address
-        HttpNettyServerBootstrapFactory factory = 
getComponent().getOrCreateHttpNettyServerBootstrapFactory(answer);
+        HttpServerBootstrapFactory factory = 
getComponent().getOrCreateHttpNettyServerBootstrapFactory(answer);
         // force using our server bootstrap factory
         answer.setNettyServerBootstrapFactory(factory);
         return answer;

http://git-wip-us.apache.org/repos/asf/camel/blob/aac94287/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
index e556cba..64c1441 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerChannelHandler.java
@@ -62,10 +62,7 @@ public class HttpServerChannelHandler extends 
ServerChannelHandler {
         // store request, as this channel handler is created per pipeline
         request = (HttpRequest) messageEvent.getMessage();
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Message received: {}", request);
-            LOG.debug("   is keep-alive: {}", isKeepAlive(request));
-        }
+        LOG.debug("Message received: {}", request);
 
         if (is100ContinueExpected(request)) {
             // send back http 100 response to continue

http://git-wip-us.apache.org/repos/asf/camel/blob/aac94287/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerMultiplexChannelHandler.java
----------------------------------------------------------------------
diff --git 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerMultiplexChannelHandler.java
 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerMultiplexChannelHandler.java
index 9237281..3760d2a 100644
--- 
a/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerMultiplexChannelHandler.java
+++ 
b/components/camel-netty-http/src/main/java/org/apache/camel/component/netty/http/handlers/HttpServerMultiplexChannelHandler.java
@@ -74,10 +74,7 @@ public class HttpServerMultiplexChannelHandler extends 
SimpleChannelUpstreamHand
         // store request, as this channel handler is created per pipeline
         HttpRequest request = (HttpRequest) messageEvent.getMessage();
 
-        if (LOG.isDebugEnabled()) {
-            LOG.debug("Message received: {}", request);
-            LOG.debug("   is keep-alive: {}", isKeepAlive(request));
-        }
+        LOG.debug("Message received: {}", request);
 
         HttpServerChannelHandler handler = getHandler(request);
         if (handler != null) {

http://git-wip-us.apache.org/repos/asf/camel/blob/aac94287/components/camel-netty-http/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-netty-http/src/test/resources/log4j.properties 
b/components/camel-netty-http/src/test/resources/log4j.properties
index d7285ad..df84584 100644
--- a/components/camel-netty-http/src/test/resources/log4j.properties
+++ b/components/camel-netty-http/src/test/resources/log4j.properties
@@ -22,6 +22,7 @@ log4j.rootLogger=INFO, file
 
 # uncomment the following to enable camel debugging
 #log4j.logger.org.apache.camel.component.netty=TRACE
+log4j.logger.org.apache.camel.component.netty.http=DEBUG
 #log4j.logger.org.apache.camel=DEBUG
 #log4j.logger.org.jboss.netty=TRACE
 

Reply via email to