You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ni...@apache.org on 2013/05/28 10:54:52 UTC

svn commit: r1486823 [1/3] - in /cxf/trunk/rt: ./ transports/http-netty/ transports/http-netty/netty-client/ transports/http-netty/netty-client/src/ transports/http-netty/netty-client/src/main/ transports/http-netty/netty-client/src/main/java/ transpor...

Author: ningjiang
Date: Tue May 28 08:54:49 2013
New Revision: 1486823

URL: http://svn.apache.org/r1486823
Log:
CXF-5041 Added netty http transport for CXF

Added:
    cxf/trunk/rt/transports/http-netty/
    cxf/trunk/rt/transports/http-netty/netty-client/
    cxf/trunk/rt/transports/http-netty/netty-client/pom.xml
    cxf/trunk/rt/transports/http-netty/netty-client/src/
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/CxfResponseCallBack.java
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientHandler.java
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientPipelineFactory.java
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientRequest.java
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactory.java
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/resources/
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/resources/META-INF/
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/resources/META-INF/cxf/
    cxf/trunk/rt/transports/http-netty/netty-client/src/main/resources/META-INF/cxf/bus-extensions.txt
    cxf/trunk/rt/transports/http-netty/netty-client/src/test/
    cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/
    cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/
    cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/
    cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/
    cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/
    cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/
    cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/
    cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/
    cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactoryTest.java
    cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/integration/
    cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/integration/NettyClientTest.java
    cxf/trunk/rt/transports/http-netty/netty-server/
    cxf/trunk/rt/transports/http-netty/netty-server/pom.xml
    cxf/trunk/rt/transports/http-netty/netty-server/src/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpContextHandler.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestination.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestinationFactory.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpHandler.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngine.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngineFactory.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServletHandler.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpServletPipelineFactory.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/ServerEngine.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/interceptor/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/interceptor/ChannelInterceptor.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/interceptor/HttpSessionInterceptor.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/interceptor/NettyInterceptor.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/ChannelThreadLocal.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/HttpSessionThreadLocal.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpServletRequest.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyHttpSession.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyServletContext.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyServletInputStream.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyServletOutputStream.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/NettyServletResponse.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/servlet/URIParser.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/session/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/session/DefaultHttpSessionStore.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/session/HttpSessionStore.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/util/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/util/Utils.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/resources/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/resources/META-INF/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/resources/META-INF/cxf/
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/resources/META-INF/cxf/bus-extensions.txt
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestinationTest.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngineFactoryTest.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/NettyHttpServerEngineTest.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/NettyHttpTestHandler.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/integration/
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/integration/NettyServerTest.java
Modified:
    cxf/trunk/rt/pom.xml

Modified: cxf/trunk/rt/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/pom.xml?rev=1486823&r1=1486822&r2=1486823&view=diff
==============================================================================
--- cxf/trunk/rt/pom.xml (original)
+++ cxf/trunk/rt/pom.xml Tue May 28 08:54:49 2013
@@ -49,6 +49,8 @@
         <module>transports/http</module>
         <module>transports/http-jetty</module>
         <module>transports/http-hc</module>
+        <module>transports/http-netty/netty-server</module>
+        <module>transports/http-netty/netty-client</module>
         <module>transports/jms</module>
         <module>transports/udp</module>
         <module>ws/policy</module>

Added: cxf/trunk/rt/transports/http-netty/netty-client/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-client/pom.xml?rev=1486823&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-client/pom.xml (added)
+++ cxf/trunk/rt/transports/http-netty/netty-client/pom.xml Tue May 28 08:54:49 2013
@@ -0,0 +1,114 @@
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.cxf</groupId>
+    <artifactId>cxf-rt-transports-http-netty-client</artifactId>
+    <packaging>jar</packaging>
+    <version>3.0.0-SNAPSHOT</version>
+    <name>Apache CXF Runtime HTTP Netty Client Transport</name>
+    <description>Apache CXF Runtime HTTP Netty Client Transport</description>
+    <url>http://cxf.apache.org</url>
+
+    <parent>
+        <groupId>org.apache.cxf</groupId>
+        <artifactId>cxf-parent</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+        <relativePath>../../../parent/pom.xml</relativePath>
+    </parent>
+
+    <properties>
+        <netty-version>3.6.5.Final</netty-version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty</artifactId>
+            <version>${netty-version}</version>
+        </dependency>
+
+        <dependency>
+            <!-- we don't implement the servlet 3.0 specification here -->
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_2.5_spec</artifactId>
+            <version>1.1.2</version>
+            <scope>provided</scope>
+            <optional>true</optional>
+        </dependency>
+
+        <!-- testing -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymock</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-testutils</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <!-- Need to run some integration with jaxws frond end -->
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxws</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+        <!-- Need to run some integration with http-jetty -->
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http-jetty</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <defaultGoal>install</defaultGoal>
+
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.4</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+
+        </plugins>
+    </build>
+
+</project>

Added: cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/CxfResponseCallBack.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/CxfResponseCallBack.java?rev=1486823&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/CxfResponseCallBack.java (added)
+++ cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/CxfResponseCallBack.java Tue May 28 08:54:49 2013
@@ -0,0 +1,27 @@
+/**
+ * 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.cxf.transport.http.netty.client;
+
+import org.jboss.netty.handler.codec.http.HttpResponse;
+
+public interface CxfResponseCallBack {
+
+    void responseReceived(HttpResponse response);
+}

Added: cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientHandler.java?rev=1486823&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientHandler.java (added)
+++ cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientHandler.java Tue May 28 08:54:49 2013
@@ -0,0 +1,67 @@
+/**
+ * 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.cxf.transport.http.netty.client;
+
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.LinkedBlockingDeque;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelHandlerContext;
+import org.jboss.netty.channel.MessageEvent;
+import org.jboss.netty.channel.SimpleChannelHandler;
+import org.jboss.netty.handler.codec.http.HttpResponse;
+
+public class NettyHttpClientHandler extends SimpleChannelHandler {
+
+    @Override
+    public void messageReceived(ChannelHandlerContext ctx, MessageEvent e)
+        throws Exception {
+        HttpResponse response = (HttpResponse)e.getMessage();
+        Channel ch = ctx.getChannel();
+        BlockingQueue<NettyHttpClientRequest> sendedQueue = (BlockingQueue<NettyHttpClientRequest>)ch.getAttachment();
+        NettyHttpClientRequest request = sendedQueue.poll();
+        request.setResponse(response);
+        // calling the callback here
+        request.getCxfResponseCallback().responseReceived(response);
+    }
+
+
+    @Override
+    public void writeRequested(ChannelHandlerContext ctx, MessageEvent e)
+        throws Exception {
+        Object p = e.getMessage();
+        // need to deal with the request
+        if (p instanceof NettyHttpClientRequest) {
+            NettyHttpClientRequest request = (NettyHttpClientRequest)e.getMessage();
+            Channel ch = ctx.getChannel();
+            BlockingQueue<NettyHttpClientRequest> sendedQueue = 
+                (BlockingQueue<NettyHttpClientRequest>)ch.getAttachment();
+            if (sendedQueue == null) {
+                sendedQueue = new LinkedBlockingDeque<NettyHttpClientRequest>();
+                ch.setAttachment(sendedQueue);
+            }
+            sendedQueue.put(request);
+            ctx.getChannel().write(request.getRequest());
+        } else {
+            super.writeRequested(ctx, e);
+        }
+    }
+
+}

Added: cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientPipelineFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientPipelineFactory.java?rev=1486823&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientPipelineFactory.java (added)
+++ cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientPipelineFactory.java Tue May 28 08:54:49 2013
@@ -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.cxf.transport.http.netty.client;
+
+import org.jboss.netty.channel.ChannelPipeline;
+import org.jboss.netty.channel.ChannelPipelineFactory;
+import org.jboss.netty.channel.Channels;
+import org.jboss.netty.handler.codec.http.HttpChunkAggregator;
+import org.jboss.netty.handler.codec.http.HttpRequestEncoder;
+import org.jboss.netty.handler.codec.http.HttpResponseDecoder;
+import org.jboss.netty.handler.stream.ChunkedWriteHandler;
+
+public class NettyHttpClientPipelineFactory implements ChannelPipelineFactory {
+    @Override
+    public ChannelPipeline getPipeline() throws Exception {
+        ChannelPipeline pipeline = Channels.pipeline();
+
+        pipeline.addLast("decoder", new HttpResponseDecoder());
+        pipeline.addLast("aggregator", new HttpChunkAggregator(65536));
+        pipeline.addLast("encoder", new HttpRequestEncoder());
+        pipeline.addLast("chunkedWriter", new ChunkedWriteHandler());
+        pipeline.addLast("client", new NettyHttpClientHandler());
+        return pipeline;
+
+    }
+}

Added: cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientRequest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientRequest.java?rev=1486823&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientRequest.java (added)
+++ cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpClientRequest.java Tue May 28 08:54:49 2013
@@ -0,0 +1,93 @@
+/**
+ * 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.cxf.transport.http.netty.client;
+
+import java.net.URI;
+import org.jboss.netty.handler.codec.http.DefaultHttpRequest;
+import org.jboss.netty.handler.codec.http.HttpMethod;
+import org.jboss.netty.handler.codec.http.HttpRequest;
+import org.jboss.netty.handler.codec.http.HttpResponse;
+import org.jboss.netty.handler.codec.http.HttpVersion;
+
+public class NettyHttpClientRequest {
+
+    private HttpRequest request;
+    private HttpResponse response;
+    private URI uri;
+    private CxfResponseCallBack cxfResponseCallback;
+    private int connectionTimeout;
+    private int receiveTimeout;
+
+    public NettyHttpClientRequest(URI requestUri, String method) {
+        this.uri = requestUri;
+        this.request  = 
+            new DefaultHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.valueOf(method), uri.getPath().toString());
+        // setup the default headers
+        request.setHeader("Connection", "keep-alive");
+        request.setHeader("Host", uri.getHost() + ":" + uri.getPort());
+
+    }
+
+    public HttpRequest getRequest() {
+        return request;
+    }
+
+    public void setRequest(HttpRequest request) {
+        this.request = request;
+    }
+
+    public HttpResponse getResponse() {
+        return response;
+    }
+
+    public void setResponse(HttpResponse response) {
+        this.response = response;
+    }
+
+    public URI getUri() {
+        return uri;
+    }
+
+    public void setCxfResponseCallback(CxfResponseCallBack callback) {
+        this.cxfResponseCallback = callback;
+    }
+
+    public CxfResponseCallBack getCxfResponseCallback() {
+        return cxfResponseCallback;
+    }
+
+    public void setConnectionTimeout(int timeout) {
+        this.connectionTimeout = timeout;
+    }
+
+    public int getConnectionTimeout() {
+        return connectionTimeout;
+    }
+
+    public void setReceiveTimeout(int timeout) {
+        this.receiveTimeout = timeout;
+    }
+
+    public int getReceiveTimeout() {
+        return receiveTimeout;
+    }
+
+
+}

Added: cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java?rev=1486823&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java (added)
+++ cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduit.java Tue May 28 08:54:49 2013
@@ -0,0 +1,486 @@
+/**
+ * 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.cxf.transport.http.netty.client;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PushbackInputStream;
+import java.net.HttpURLConnection;
+import java.net.InetSocketAddress;
+import java.net.MalformedURLException;
+import java.net.SocketTimeoutException;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.util.StringUtils;
+import org.apache.cxf.helpers.HttpHeaderHelper;
+import org.apache.cxf.io.CacheAndWriteOutputStream;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageUtils;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.http.Headers;
+import org.apache.cxf.transport.http.URLConnectionHTTPConduit;
+import org.apache.cxf.transport.https.HttpsURLConnectionInfo;
+import org.apache.cxf.transports.http.configuration.HTTPClientPolicy;
+import org.apache.cxf.version.Version;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.jboss.netty.buffer.ChannelBuffer;
+import org.jboss.netty.buffer.ChannelBufferInputStream;
+import org.jboss.netty.buffer.ChannelBufferOutputStream;
+import org.jboss.netty.buffer.ChannelBuffers;
+import org.jboss.netty.channel.Channel;
+import org.jboss.netty.channel.ChannelFuture;
+import org.jboss.netty.channel.ChannelFutureListener;
+import org.jboss.netty.handler.codec.http.HttpResponse;
+
+public class NettyHttpConduit extends URLConnectionHTTPConduit {
+    public static final String USE_ASYNC = "use.async.http.conduit";
+    final NettyHttpConduitFactory factory;
+    public NettyHttpConduit(Bus b, EndpointInfo ei, EndpointReferenceType t, NettyHttpConduitFactory conduitFactory)
+        throws IOException {
+        super(b, ei, t);
+        factory = conduitFactory;
+    }
+
+    public NettyHttpConduitFactory getNettyHttpConduitFactory() {
+        return factory;
+    }
+
+    // Using Netty API directly
+    protected void setupConnection(Message message, URI uri, HTTPClientPolicy csPolicy) throws IOException {
+
+        String s = uri.getScheme();
+        if (!"http".equals(s) && !"https".equals(s)) {
+            throw new MalformedURLException("unknown protocol: " + s);
+        }
+
+        if (StringUtils.isEmpty(uri.getPath())) {
+            //hc needs to have the path be "/"
+            uri = uri.resolve("/");
+        }
+
+        message.put("http.scheme", uri.getScheme());
+        String httpRequestMethod =
+                (String)message.get(Message.HTTP_REQUEST_METHOD);
+        if (httpRequestMethod == null) {
+            httpRequestMethod = "POST";
+            message.put(Message.HTTP_REQUEST_METHOD, httpRequestMethod);
+        }
+        // setup a new NettyHttpClientRequest
+        final NettyHttpClientRequest request = new NettyHttpClientRequest(uri, httpRequestMethod);
+        final int ctimeout = determineConnectionTimeout(message, csPolicy);
+        final int rtimeout = determineReceiveTimeout(message, csPolicy);
+        request.setConnectionTimeout(ctimeout);
+        request.setReceiveTimeout(rtimeout);
+        request.getRequest().setChunked(true);
+        request.getRequest().setHeader(Message.CONTENT_TYPE, (String)message.get(Message.CONTENT_TYPE));
+        // need to socket connection timeout
+
+        message.put(NettyHttpClientRequest.class, request);
+    }
+
+    protected OutputStream createOutputStream(Message message,
+                                              boolean needToCacheRequest,
+                                              boolean isChunking,
+                                              int chunkThreshold) throws IOException {
+
+        NettyHttpClientRequest entity = message.get(NettyHttpClientRequest.class);
+        NettyWrappedOutputStream out = new NettyWrappedOutputStream(message,
+                needToCacheRequest,
+                isChunking,
+                chunkThreshold,
+                getConduitName(),
+                entity.getUri());
+        entity.getRequest().setContent(out.getOutBuffer());
+        return out;
+
+
+    }
+
+    public class NettyWrappedOutputStream extends WrappedOutputStream {
+        final HTTPClientPolicy csPolicy;
+        NettyHttpClientRequest entity;
+        volatile HttpResponse httpResponse;
+        volatile Throwable exception;
+        volatile Channel channel;
+        boolean isAsync;
+        ChannelBuffer outBuffer;
+        OutputStream outputStream;
+
+        protected NettyWrappedOutputStream(Message message, boolean possibleRetransmit,
+                                           boolean isChunking, int chunkThreshold, String conduitName, URI url) {
+            super(message, possibleRetransmit, isChunking, chunkThreshold, conduitName, url);
+            csPolicy = getClient(message);
+            entity  = message.get(NettyHttpClientRequest.class);
+            int bufSize = csPolicy.getChunkLength() > 0 ? csPolicy.getChunkLength() : 16320;
+            outBuffer = ChannelBuffers.dynamicBuffer(bufSize);
+            outputStream = new ChannelBufferOutputStream(outBuffer);
+        }
+
+        protected ChannelBuffer getOutBuffer() {
+            return outBuffer;
+        }
+
+
+        protected synchronized HttpResponse getHttpResponse() throws IOException {
+            while (httpResponse == null) {
+                if (exception == null) { //already have an exception, skip waiting
+                    try {
+                        wait(entity.getReceiveTimeout());
+                    } catch (InterruptedException e) {
+                        throw new IOException(e);
+                    }
+                }
+                if (httpResponse == null) {
+
+                    if (exception != null) {
+                        if (exception instanceof IOException) {
+                            throw (IOException)exception;
+                        }
+                        if (exception instanceof RuntimeException) {
+                            throw (RuntimeException)exception;
+                        }
+                        throw new IOException(exception);
+                    }
+
+                    throw new SocketTimeoutException("Read Timeout");
+                }
+            }
+            return httpResponse;
+        }
+
+
+        protected synchronized Channel getChannel() throws IOException {
+            while (channel == null) {
+                if (exception == null) { //already have an exception, skip waiting
+                    try {
+                        // connection timeout
+                        wait(entity.getConnectionTimeout());
+                    } catch (InterruptedException e) {
+                        throw new IOException(e);
+                    }
+                }
+                if (channel == null) {
+
+                    if (exception != null) {
+                        if (exception instanceof IOException) {
+                            throw (IOException)exception;
+                        }
+                        if (exception instanceof RuntimeException) {
+                            throw (RuntimeException)exception;
+                        }
+                        throw new IOException(exception);
+                    }
+
+                    throw new SocketTimeoutException("Connection Timeout");
+                }
+            }
+            return channel;
+
+        }
+
+
+        @Override
+        protected void setupWrappedStream() throws IOException {
+            connect(true);
+            wrappedStream =  new OutputStream() {
+                public void write(byte b[], int off, int len) throws IOException {
+                    outputStream.write(b, off, len);
+                }
+                public void write(int b) throws IOException {
+                    outputStream.write(b);
+                }
+                public void close() throws IOException {
+                    // Setup the call back for sending the message
+                    ChannelFutureListener listener = new ChannelFutureListener() {
+                        @Override
+                        public void operationComplete(ChannelFuture future) throws Exception {
+                            if (!future.isSuccess()) {
+                                setException(future.getCause());
+                            }
+                        }
+                    };
+                    ChannelFuture channelFuture = getChannel().write(entity);
+                    channelFuture.addListener(listener);
+                    outputStream.close();
+                }
+            };
+
+            // If we need to cache for retransmission, store data in a
+            // CacheAndWriteOutputStream. Otherwise write directly to the output stream.
+            if (cachingForRetransmission) {
+                cachedStream = new CacheAndWriteOutputStream(wrappedStream);
+                wrappedStream = cachedStream;
+            }
+        }
+
+        protected void connect(boolean output) {
+
+            ChannelFuture connFuture = 
+                factory.getBootstrap().connect(new InetSocketAddress(url.getHost(), url.getPort()));
+
+            // Setup the call back on the NettyHttpClientRequest
+            ChannelFutureListener listener = new ChannelFutureListener() {
+
+                @Override
+                public void operationComplete(ChannelFuture future) throws Exception {
+                    if (future.isSuccess()) {
+                        setChannel(future.getChannel());
+                    } else {
+                        setException((Exception) future.getCause());
+                    }
+                }
+            };
+
+            connFuture.addListener(listener);
+
+            if (!output) {
+                entity.getRequest().removeHeader("Transfer-Encoding");
+                entity.getRequest().removeHeader("Content-Type");
+                entity.getRequest().setContent(null);
+            }
+
+            // setup the CxfResponseCallBack
+            CxfResponseCallBack callBack = new CxfResponseCallBack() {
+                @Override
+                public void responseReceived(HttpResponse response) {
+                    setHttpResponse(response);
+                }
+            };
+            entity.setCxfResponseCallback(callBack);
+
+        }
+
+        @Override
+        protected HttpsURLConnectionInfo getHttpsURLConnectionInfo() throws IOException {
+            // TODO to setup the SSL info
+            return null;
+        }
+
+        @Override
+        protected void setProtocolHeaders() throws IOException {
+            Headers h = new Headers(outMessage);
+            entity.getRequest().setHeader(Message.CONTENT_TYPE, h.determineContentType());
+            boolean addHeaders = MessageUtils.isTrue(outMessage.getContextualProperty(Headers.ADD_HEADERS_PROPERTY));
+
+            for (Map.Entry<String, List<String>> header : h.headerMap().entrySet()) {
+                if (HttpHeaderHelper.CONTENT_TYPE.equalsIgnoreCase(header.getKey())) {
+                    continue;
+                }
+                if (addHeaders || HttpHeaderHelper.COOKIE.equalsIgnoreCase(header.getKey())) {
+                    for (String s : header.getValue()) {
+                        entity.getRequest().addHeader(HttpHeaderHelper.COOKIE, s);
+                    }
+                } else if (!"Content-Length".equalsIgnoreCase(header.getKey())) {
+                    StringBuilder b = new StringBuilder();
+                    for (int i = 0; i < header.getValue().size(); i++) {
+                        b.append(header.getValue().get(i));
+                        if (i + 1 < header.getValue().size()) {
+                            b.append(',');
+                        }
+                    }
+                    entity.getRequest().setHeader(header.getKey(), b.toString());
+                }
+                if (!entity.getRequest().containsHeader("User-Agent")) {
+                    entity.getRequest().setHeader("User-Agent", Version.getCompleteVersionString());
+                }
+            }
+        }
+
+        @Override
+        protected void setFixedLengthStreamingMode(int i) {
+            // Here we can set the Content-Length
+            entity.getRequest().setHeader("Content-Length", i);
+            entity.getRequest().setChunked(false);
+        }
+
+        @Override
+        protected int getResponseCode() throws IOException {
+            return getHttpResponse().getStatus().getCode();
+        }
+
+        @Override
+        protected String getResponseMessage() throws IOException {
+            return getHttpResponse().getStatus().getReasonPhrase();
+        }
+
+        @Override
+        protected void updateResponseHeaders(Message inMessage) throws IOException {
+            Headers h = new Headers(inMessage);
+            inMessage.put(Message.CONTENT_TYPE, readHeaders(h));
+            cookies.readFromHeaders(h);
+        }
+
+        private String readHeaders(Headers h) throws IOException {
+            Set<String> headerNames = getHttpResponse().getHeaderNames();
+            String ct = null;
+            for (String name : headerNames) {
+                List<String> s = getHttpResponse().getHeaders(name);
+                h.headerMap().put(name, s);
+                if (Message.CONTENT_TYPE.equalsIgnoreCase(name)) {
+                    ct = getHttpResponse().getHeader(name);
+                }
+            }
+            return ct;
+        }
+
+        @Override
+        protected void handleResponseAsync() throws IOException {
+            isAsync = true;
+        }
+
+        @Override
+        protected void closeInputStream() throws IOException {
+            //We just clear the buffer
+            getHttpResponse().getContent().clear();
+        }
+
+        @Override
+        protected boolean usingProxy() {
+            // TODO we need to support it
+            return false;
+        }
+
+        @Override
+        protected InputStream getInputStream() throws IOException {
+            return new ChannelBufferInputStream(getHttpResponse().getContent());
+        }
+
+        @Override
+        protected InputStream getPartialResponse() throws IOException {
+            InputStream in = null;
+            int responseCode = getResponseCode();
+            if (responseCode == HttpURLConnection.HTTP_ACCEPTED
+                    || responseCode == HttpURLConnection.HTTP_OK) {
+
+                String head = httpResponse.getHeader(HttpHeaderHelper.CONTENT_LENGTH);
+                int cli = 0;
+                if (head != null) {
+                    cli = Integer.parseInt(head);
+                }
+                head = httpResponse.getHeader(HttpHeaderHelper.TRANSFER_ENCODING);
+                boolean isChunked = head != null &&  HttpHeaderHelper.CHUNKED.equalsIgnoreCase(head);
+                head = httpResponse.getHeader(HttpHeaderHelper.CONNECTION);
+                boolean isEofTerminated = head != null &&  HttpHeaderHelper.CLOSE.equalsIgnoreCase(head);
+                if (cli > 0) {
+                    in = getInputStream();
+                } else if (isChunked || isEofTerminated) {
+                    // ensure chunked or EOF-terminated response is non-empty
+                    try {
+                        @SuppressWarnings("resource")
+                        PushbackInputStream pin =
+                                new PushbackInputStream(getInputStream());
+                        int c = pin.read();
+                        if (c != -1) {
+                            pin.unread((byte)c);
+                            in = pin;
+                        }
+                    } catch (IOException ioe) {
+                        // ignore
+                    }
+                }
+            }
+            return in;
+        }
+
+        @Override
+        protected void setupNewConnection(String newURL) throws IOException {
+            httpResponse = null;
+            isAsync = false;
+            exception = null;
+            if (channel != null) {
+                channel.close();
+                channel = null;
+            }
+
+            try {
+                this.url = new URI(newURL);
+                setupConnection(outMessage, this.url, csPolicy);
+                entity = outMessage.get(NettyHttpClientRequest.class);
+                //reset the buffers
+                outBuffer.clear();
+                outputStream = new ChannelBufferOutputStream(outBuffer);
+
+            } catch (URISyntaxException e) {
+                throw new IOException(e);
+            }
+        }
+
+        @Override
+        protected void retransmitStream() throws IOException {
+            cachingForRetransmission = false; //already cached
+            setupWrappedStream();
+            cachedStream.writeCacheTo(wrappedStream);
+            wrappedStream.flush();
+            wrappedStream.close();
+        }
+
+        @Override
+        protected void updateCookiesBeforeRetransmit() throws IOException {
+            Headers h = new Headers();
+            readHeaders(h);
+            cookies.readFromHeaders(h);
+        }
+
+        @Override
+        public void thresholdReached() throws IOException {
+            entity.getRequest().setChunked(true);
+        }
+
+        protected synchronized void setHttpResponse(HttpResponse r) {
+            httpResponse = r;
+            if (isAsync) {
+                //got a response, need to start the response processing now
+                try {
+                    handleResponseOnWorkqueue(false, true);
+                    isAsync = false; // don't trigger another start on next block. :-)
+                } catch (Exception ex) {
+                    //ignore, we'll try again on the next consume;
+                }
+            }
+            notifyAll();
+        }
+
+        protected synchronized void setException(Throwable ex) {
+            exception = ex;
+            if (isAsync) {
+                //got a response, need to start the response processing now
+                try {
+                    handleResponseOnWorkqueue(false, true);
+                    isAsync = false; // don't trigger another start on next block. :-)
+                } catch (Exception ex2) {
+                    ex2.printStackTrace();
+                }
+            }
+            notifyAll();
+        }
+
+        protected synchronized void setChannel(Channel ch) {
+            channel = ch;
+            notifyAll();
+        }
+    }
+
+
+}

Added: cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactory.java?rev=1486823&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactory.java (added)
+++ cxf/trunk/rt/transports/http-netty/netty-client/src/main/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactory.java Tue May 28 08:54:49 2013
@@ -0,0 +1,94 @@
+/**
+ * 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.cxf.transport.http.netty.client;
+
+import java.io.IOException;
+import javax.annotation.Resource;
+import org.apache.cxf.Bus;
+import org.apache.cxf.buslifecycle.BusLifeCycleListener;
+import org.apache.cxf.buslifecycle.BusLifeCycleManager;
+import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.http.HTTPConduit;
+import org.apache.cxf.transport.http.HTTPConduitFactory;
+import org.apache.cxf.transport.http.HTTPTransportFactory;
+import org.apache.cxf.ws.addressing.EndpointReferenceType;
+import org.jboss.netty.bootstrap.ClientBootstrap;
+import org.jboss.netty.channel.socket.nio.NioClientSocketChannelFactory;
+
+@NoJSR250Annotations(unlessNull = "bus")
+public class NettyHttpConduitFactory implements BusLifeCycleListener, HTTPConduitFactory {
+
+    boolean isShutdown;
+
+    private final ClientBootstrap bootstrap;
+
+    public NettyHttpConduitFactory() {
+        //TODO setup the bootstrap thread pool according to the configuration
+        bootstrap = new ClientBootstrap(
+                new NioClientSocketChannelFactory());
+        bootstrap.setPipelineFactory(new NettyHttpClientPipelineFactory());
+    }
+
+    public NettyHttpConduitFactory(Bus b) {
+        this();
+        addListener(b);
+    }
+
+    @Resource
+    public void setBus(Bus b) {
+        addListener(b);
+    }
+
+    private void addListener(Bus b) {
+        b.getExtension(BusLifeCycleManager.class).registerLifeCycleListener(this);
+    }
+
+    @Override
+    public HTTPConduit createConduit(HTTPTransportFactory f, EndpointInfo localInfo, EndpointReferenceType target)
+        throws IOException {
+        return new NettyHttpConduit(f.getBus(), localInfo, target, this);
+    }
+
+    @Override
+    public void initComplete() {
+        isShutdown = false;
+    }
+
+    @Override
+    public void preShutdown() {
+        isShutdown = true;
+    }
+
+    @Override
+    public void postShutdown() {
+        // shutdown the bootstrap
+        bootstrap.shutdown();
+    }
+
+    public boolean isShutdown() {
+        return isShutdown;
+    }
+
+    public ClientBootstrap getBootstrap() {
+        return bootstrap;
+    }
+
+}

Added: cxf/trunk/rt/transports/http-netty/netty-client/src/main/resources/META-INF/cxf/bus-extensions.txt
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-client/src/main/resources/META-INF/cxf/bus-extensions.txt?rev=1486823&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-client/src/main/resources/META-INF/cxf/bus-extensions.txt (added)
+++ cxf/trunk/rt/transports/http-netty/netty-client/src/main/resources/META-INF/cxf/bus-extensions.txt Tue May 28 08:54:49 2013
@@ -0,0 +1 @@
+org.apache.cxf.transport.http.netty.client.NettyHttpConduitFactory::true

Added: cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactoryTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactoryTest.java?rev=1486823&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactoryTest.java (added)
+++ cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/NettyHttpConduitFactoryTest.java Tue May 28 08:54:49 2013
@@ -0,0 +1,69 @@
+/**
+ * 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.cxf.transport.http.netty.client;
+
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.transport.http.HTTPConduitFactory;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class NettyHttpConduitFactoryTest extends Assert {
+    Bus bus;
+
+    @BeforeClass
+    public static void classUp() {
+        // Get rid of any notion of a default bus set by other
+        // rogue tests.
+        BusFactory.setDefaultBus(null);
+    }
+
+    @AfterClass
+    public static void classDown() {
+        // Clean up.
+        BusFactory.setDefaultBus(null);
+    }
+
+    @After
+    public void tearDown() {
+        if (bus != null) {
+            bus.shutdown(false);
+            bus = null;
+        }
+    }
+
+    @Test
+    public void testLoadingHttpConduitFactory() throws Exception {
+        bus = BusFactory.getDefaultBus(true);
+
+        assertNotNull("Cannot get bus", bus);
+
+        // Make sure we got the Transport Factory.
+        HTTPConduitFactory factory =
+                bus.getExtension(HTTPConduitFactory.class);
+        assertNotNull("Cannot get HTTPConduitFactory", factory);
+
+        assertTrue(NettyHttpConduitFactory.class.isInstance(factory));
+
+    }
+}

Added: cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/integration/NettyClientTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/integration/NettyClientTest.java?rev=1486823&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/integration/NettyClientTest.java (added)
+++ cxf/trunk/rt/transports/http-netty/netty-client/src/test/java/org/apache/cxf/transport/http/netty/client/integration/NettyClientTest.java Tue May 28 08:54:49 2013
@@ -0,0 +1,124 @@
+/**
+ * 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.cxf.transport.http.netty.client.integration;
+
+import java.net.URL;
+import java.util.concurrent.ExecutionException;
+import javax.xml.ws.AsyncHandler;
+import javax.xml.ws.Endpoint;
+import javax.xml.ws.Response;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
+import org.apache.hello_world_soap_http.Greeter;
+import org.apache.hello_world_soap_http.SOAPService;
+import org.apache.hello_world_soap_http.types.GreetMeLaterResponse;
+import org.apache.hello_world_soap_http.types.GreetMeResponse;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class NettyClientTest extends AbstractBusClientServerTestBase {
+
+    public static final String PORT = allocatePort(NettyClientTest.class);
+    public static final String PORT_INV = allocatePort(NettyClientTest.class, 2);
+
+
+    static Endpoint ep;
+
+    static Greeter g;
+
+    @BeforeClass
+    public static void start() throws Exception {
+        Bus b = createStaticBus();
+        BusFactory.setThreadDefaultBus(b);
+        ep = Endpoint.publish("http://localhost:" + PORT + "/SoapContext/SoapPort",
+                new org.apache.hello_world_soap_http.GreeterImpl());
+
+        URL wsdl = NettyClientTest.class.getResource("/wsdl/hello_world.wsdl");
+        assertNotNull("WSDL is null", wsdl);
+
+        SOAPService service = new SOAPService(wsdl);
+        assertNotNull("Service is null", service);
+
+        g = service.getSoapPort();
+        assertNotNull("Port is null", g);
+    }
+
+    @AfterClass
+    public static void stop() throws Exception {
+        if (g != null) {
+            ((java.io.Closeable)g).close();
+        }
+        if (ep != null) {
+            ep.stop();
+        }
+        ep = null;
+    }
+
+    @Test
+    public void testInvocation() throws Exception {
+        updateAddressPort(g, PORT);
+        String response = g.greetMe("test");
+        assertEquals("Get a wrong response", "Hello test", response);
+    }
+
+    @Test
+    public void testCallAsync() throws Exception {
+        updateAddressPort(g, PORT);
+        GreetMeResponse resp = (GreetMeResponse)g.greetMeAsync("asyncTest", new AsyncHandler<GreetMeResponse>() {
+            public void handleResponse(Response<GreetMeResponse> res) {
+                try {
+                    res.get().getResponseType();
+                } catch (InterruptedException e) {
+                    e.printStackTrace();
+                } catch (ExecutionException e) {
+                    e.printStackTrace();
+                }
+            }
+        }).get();
+        assertEquals("Hello asyncTest", resp.getResponseType());
+
+        MyLaterResponseHandler handler = new MyLaterResponseHandler();
+        g.greetMeLaterAsync(1000, handler).get();
+        // need to check the result here
+        assertEquals("Hello, finally!", handler.getResponse().getResponseType());
+
+
+    }
+
+    private class MyLaterResponseHandler implements AsyncHandler<GreetMeLaterResponse> {
+        GreetMeLaterResponse response;
+        @Override
+        public void handleResponse(Response<GreetMeLaterResponse> res) {
+            try {
+                response = res.get();
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            } catch (ExecutionException e) {
+                e.printStackTrace();
+            }
+        }
+
+        GreetMeLaterResponse getResponse() {
+            return response;
+        }
+
+    }
+}

Added: cxf/trunk/rt/transports/http-netty/netty-server/pom.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-server/pom.xml?rev=1486823&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-server/pom.xml (added)
+++ cxf/trunk/rt/transports/http-netty/netty-server/pom.xml Tue May 28 08:54:49 2013
@@ -0,0 +1,107 @@
+<!--
+  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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.cxf</groupId>
+    <artifactId>cxf-rt-transports-http-netty-server</artifactId>
+    <packaging>jar</packaging>
+    <version>3.0.0-SNAPSHOT</version>
+    <name>Apache CXF Runtime HTTP Netty Server Transport</name>
+    <description>Apache CXF Runtime HTTP Netty Server Transport</description>
+    <url>http://cxf.apache.org</url>
+
+    <parent>
+        <groupId>org.apache.cxf</groupId>
+        <artifactId>cxf-parent</artifactId>
+        <version>3.0.0-SNAPSHOT</version>
+        <relativePath>../../../parent/pom.xml</relativePath>
+    </parent>
+
+
+    <properties>
+        <netty-version>3.6.5.Final</netty-version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-transports-http</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>io.netty</groupId>
+            <artifactId>netty</artifactId>
+            <version>${netty-version}</version>
+        </dependency>
+
+        <dependency>
+            <!-- we don't implement the servlet 3.0 specification here -->
+            <groupId>org.apache.geronimo.specs</groupId>
+            <artifactId>geronimo-servlet_2.5_spec</artifactId>
+            <version>1.1.2</version>
+        </dependency>
+
+        <!-- testing -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymock</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-testutils</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- Need to run some integration with jaxws frond end -->
+        <dependency>
+            <groupId>org.apache.cxf</groupId>
+            <artifactId>cxf-rt-frontend-jaxws</artifactId>
+            <version>${project.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+    <build>
+        <defaultGoal>install</defaultGoal>
+
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>2.4</version>
+                <configuration>
+                    <source>1.6</source>
+                    <target>1.6</target>
+                </configuration>
+            </plugin>
+
+        </plugins>
+    </build>
+
+</project>

Added: cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpContextHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpContextHandler.java?rev=1486823&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpContextHandler.java (added)
+++ cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpContextHandler.java Tue May 28 08:54:49 2013
@@ -0,0 +1,80 @@
+/**
+ * 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.cxf.transport.http.netty.server;
+
+
+import java.io.IOException;
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.cxf.transport.http.netty.server.servlet.NettyServletContext;
+
+public class NettyHttpContextHandler {
+    private final ServletContext servletContext;
+    private List<NettyHttpHandler> nettyHttpHandlerList = new CopyOnWriteArrayList<NettyHttpHandler>();
+
+    public NettyHttpContextHandler(String contextPath) {
+        servletContext = new NettyServletContext(contextPath);
+    }
+
+    public void addNettyHttpHandler(NettyHttpHandler handler) {
+        // setup the servletContext for it
+        handler.setServletContext(servletContext);
+        nettyHttpHandlerList.add(handler);
+    }
+
+    public NettyHttpHandler getNettyHttpHandler(String urlName) {
+        for (NettyHttpHandler handler : nettyHttpHandlerList) {
+            if (urlName.equals(handler.getName())) {
+                return handler;
+            }
+        }
+        return null;
+    }
+
+    public boolean isEmpty() {
+        return nettyHttpHandlerList.isEmpty();
+    }
+
+    public String getContextPath() {
+        return servletContext.getContextPath();
+    }
+
+    public void removeNettyHttpHandler(String urlName) {
+        NettyHttpHandler handler = getNettyHttpHandler(urlName);
+        if (handler != null) {
+            nettyHttpHandlerList.remove(handler);
+        }
+    }
+
+    public void handle(String target, HttpServletRequest request,
+                       HttpServletResponse response) throws IOException, ServletException {
+
+        for (NettyHttpHandler handler : nettyHttpHandlerList) {
+            handler.handle(target, request, response);
+        }
+
+    }
+}

Added: cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestination.java?rev=1486823&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestination.java (added)
+++ cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestination.java Tue May 28 08:54:49 2013
@@ -0,0 +1,321 @@
+/**
+ * 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.cxf.transport.http.netty.server;
+
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.common.classloader.ClassLoaderUtils;
+import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.continuations.SuspendedInvocationException;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.io.CachedOutputStream;
+import org.apache.cxf.message.ExchangeImpl;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.message.MessageImpl;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.http.DestinationRegistry;
+import org.apache.cxf.transport.http.HTTPSession;
+import org.apache.cxf.transports.http.QueryHandler;
+import org.apache.cxf.transports.http.QueryHandlerRegistry;
+import org.apache.cxf.transports.http.StemMatchingQueryHandler;
+
+public class NettyHttpDestination extends AbstractHTTPDestination {
+
+    private static final Logger LOG =
+            LogUtils.getL7dLogger(NettyHttpDestination.class);
+    
+    protected NettyHttpServerEngine engine;
+    protected NettyHttpServerEngineFactory serverEngineFactory;
+    protected ServletContext servletContext;
+    protected ClassLoader loader;
+    protected URL nurl;
+    
+    private boolean configFinalized;
+
+    /**
+     * Constructor
+     *
+     * @param b                   the associated Bus
+     * @param registry            the associated destinationRegistry
+     * @param ei                  the endpoint info of the destination
+     * @param serverEngineFactory the serverEngineFactory which could be used to create ServerEngine
+     * @throws java.io.IOException
+     */
+    public NettyHttpDestination(Bus b, DestinationRegistry registry, 
+                                EndpointInfo ei, NettyHttpServerEngineFactory serverEngineFactory) throws IOException {
+        //Add the default port if the address is missing it
+        super(b, registry, ei, getAddressValue(ei, true).getAddress(), true);
+        loader = bus.getExtension(ClassLoader.class);
+        this.serverEngineFactory = serverEngineFactory;
+        nurl = new URL(endpointInfo.getAddress());
+    }
+
+
+    @Override
+    protected Logger getLogger() {
+        return LOG;
+    }
+
+    protected void retrieveEngine()
+        throws IOException {
+
+        engine = serverEngineFactory.retrieveNettyHttpServerEngine(nurl.getPort());
+        if (engine == null) {
+            engine = 
+                serverEngineFactory.createNettyHttpServerEngine(nurl.getHost(), nurl.getPort(), nurl.getProtocol());
+        }
+
+        assert engine != null;
+    }
+
+    public void finalizeConfig() {
+        assert !configFinalized;
+
+        try {
+            retrieveEngine();
+        } catch (Exception e) {
+            throw new RuntimeException(e.getMessage(), e);
+        }
+        configFinalized = true;
+    }
+
+    /**
+     * Activate receipt of incoming messages.
+     */
+    protected void activate() {
+        super.activate();
+        LOG.log(Level.FINE, "Activating receipt of incoming messages");
+        URL url = null;
+        try {
+            url = new URL(endpointInfo.getAddress());
+        } catch (Exception e) {
+            throw new Fault(e);
+        }
+        // setup the path for it
+
+        engine.addServant(url,
+                new NettyHttpHandler(this, contextMatchOnExact()));
+    }
+
+    /**
+     * Deactivate receipt of incoming messages.
+     */
+    protected void deactivate() {
+        super.deactivate();
+        LOG.log(Level.FINE, "Deactivating receipt of incoming messages");
+        engine.removeServant(nurl);
+    }
+
+
+    protected void doService(HttpServletRequest req,
+                             HttpServletResponse resp) throws IOException {
+        doService(servletContext, req, resp);
+    }
+
+    protected void doService(ServletContext context,
+                             HttpServletRequest req,
+                             HttpServletResponse resp) throws IOException {
+        if (context == null) {
+            context = servletContext;
+        }
+
+        if (getServer().isSetRedirectURL()) {
+            resp.sendRedirect(getServer().getRedirectURL());
+            resp.flushBuffer();
+            return;
+        }
+        QueryHandlerRegistry queryHandlerRegistry = bus.getExtension(QueryHandlerRegistry.class);
+
+        if (null != req.getQueryString() && queryHandlerRegistry != null) {
+            String reqAddr = req.getRequestURL().toString();
+            String requestURL = reqAddr + "?" + req.getQueryString();
+            String pathInfo = req.getPathInfo();
+            for (QueryHandler qh : queryHandlerRegistry.getHandlers()) {
+                boolean recognized =
+                        qh instanceof StemMatchingQueryHandler
+                                ? ((StemMatchingQueryHandler) qh).isRecognizedQuery(requestURL,
+                                    pathInfo,
+                                    endpointInfo,
+                                    contextMatchOnExact())
+                                    : qh.isRecognizedQuery(requestURL, pathInfo, endpointInfo);
+                if (recognized) {
+                    //replace the endpointInfo address with request url only for get wsdl
+                    String errorMsg = null;
+                    CachedOutputStream out = new CachedOutputStream();
+                    try {
+                        synchronized (endpointInfo) {
+                            String oldAddress = updateEndpointAddress(reqAddr);
+                            resp.setContentType(qh.getResponseContentType(requestURL, pathInfo));
+                            try {
+                                qh.writeResponse(requestURL, pathInfo, endpointInfo, out);
+                            } catch (Exception ex) {
+                                LOG.log(Level.WARNING, "writeResponse failed: ", ex);
+                                errorMsg = ex.getMessage();
+                            }
+                            endpointInfo.setAddress(oldAddress);
+                        }
+                        if (errorMsg != null) {
+                            resp.sendError(500, errorMsg);
+                        } else {
+                            out.writeCacheTo(resp.getOutputStream());
+                            resp.getOutputStream().flush();
+                        }
+                    } finally {
+                        out.close();
+                    }
+
+                    return;
+                }
+            }
+        }
+
+        // REVISIT: service on executor if associated with endpoint
+        ClassLoaderHolder origLoader = null;
+        Bus origBus = BusFactory.getAndSetThreadDefaultBus(bus);
+        try {
+            if (loader != null) {
+                origLoader = ClassLoaderUtils.setThreadContextClassloader(loader);
+            }
+            serviceRequest(context, req, resp);
+        } finally {
+            if (origBus != bus) {
+                BusFactory.setThreadDefaultBus(origBus);
+            }
+            if (origLoader != null) {
+                origLoader.reset();
+            }
+        }
+    }
+
+    protected void serviceRequest(final ServletContext context,
+                                  final HttpServletRequest req,
+                                  final HttpServletResponse resp)
+        throws IOException {
+
+        if (LOG.isLoggable(Level.FINE)) {
+            LOG.fine("Service http request on thread: " + Thread.currentThread());
+        }
+        Message inMessage = retrieveFromContinuation(req);
+
+        if (inMessage == null) {
+
+            inMessage = new MessageImpl();
+            setupMessage(inMessage, context, req, resp);
+
+            ((MessageImpl) inMessage).setDestination(this);
+
+            ExchangeImpl exchange = new ExchangeImpl();
+            exchange.setInMessage(inMessage);
+            exchange.setSession(new HTTPSession(req));
+        }
+
+        try {
+            incomingObserver.onMessage(inMessage);
+            resp.flushBuffer();
+        } catch (SuspendedInvocationException ex) {
+            if (ex.getRuntimeException() != null) {
+                throw ex.getRuntimeException();
+            }
+            //else nothing to do
+        } catch (Fault ex) {
+            Throwable cause = ex.getCause();
+            if (cause instanceof RuntimeException) {
+                throw (RuntimeException) cause;
+            } else {
+                throw ex;
+            }
+        } catch (RuntimeException ex) {
+            throw ex;
+        } finally {
+            if (LOG.isLoggable(Level.FINE)) {
+                LOG.fine("Finished servicing http request on thread: " + Thread.currentThread());
+            }
+        }
+    }
+
+
+    public ServerEngine getEngine() {
+        return engine;
+    }
+
+    protected Message retrieveFromContinuation(HttpServletRequest req) {
+        return (Message) req.getAttribute(CXF_CONTINUATION_MESSAGE);
+    }
+
+
+    protected void setupContinuation(Message inMessage,
+                                     final HttpServletRequest req,
+                                     final HttpServletResponse resp) {
+        // Here we don't support the Continuation
+    }
+
+    private synchronized String updateEndpointAddress(String addr) {
+        // only update the EndpointAddress if the base path is equal
+        // make sure we don't broke the get operation?parament query
+        String address = removeTrailingSeparator(endpointInfo.getAddress());
+        if (getBasePathForFullAddress(address)
+                .equals(removeTrailingSeparator(getStem(getBasePathForFullAddress(addr))))) {
+            endpointInfo.setAddress(addr);
+        }
+        return address;
+    }
+
+    private String removeTrailingSeparator(String addr) {
+        if (addr != null && addr.length() > 0
+                && addr.lastIndexOf('/') == addr.length() - 1) {
+            return addr.substring(0, addr.length() - 1);
+        } else {
+            return addr;
+        }
+    }
+
+    protected String getBasePathForFullAddress(String addr) {
+        try {
+            return new URL(addr).getPath();
+        } catch (MalformedURLException e) {
+            return null;
+        }
+    }
+
+    private String getStem(String baseURI) {
+        return baseURI.substring(0, baseURI.lastIndexOf("/"));
+    }
+
+    public ServletContext getServletContext() {
+        return servletContext;
+    }
+
+    public void setServletContext(ServletContext servletContext) {
+        this.servletContext = servletContext;
+    }
+
+
+}

Added: cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestinationFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestinationFactory.java?rev=1486823&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestinationFactory.java (added)
+++ cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestinationFactory.java Tue May 28 08:54:49 2013
@@ -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.cxf.transport.http.netty.server;
+
+import java.io.IOException;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.common.injection.NoJSR250Annotations;
+import org.apache.cxf.service.model.EndpointInfo;
+import org.apache.cxf.transport.http.AbstractHTTPDestination;
+import org.apache.cxf.transport.http.DestinationRegistry;
+import org.apache.cxf.transport.http.HttpDestinationFactory;
+
+@NoJSR250Annotations()
+public class NettyHttpDestinationFactory implements HttpDestinationFactory {
+
+    public AbstractHTTPDestination createDestination(EndpointInfo endpointInfo, Bus bus,
+                                                     DestinationRegistry registry) throws IOException {
+        NettyHttpServerEngineFactory serverEngineFactory = bus
+                .getExtension(NettyHttpServerEngineFactory.class);
+        return new NettyHttpDestination(bus, registry, endpointInfo, serverEngineFactory);
+    }
+
+}

Added: cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpHandler.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpHandler.java?rev=1486823&view=auto
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpHandler.java (added)
+++ cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpHandler.java Tue May 28 08:54:49 2013
@@ -0,0 +1,80 @@
+/**
+ * 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.cxf.transport.http.netty.server;
+
+import java.io.IOException;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class NettyHttpHandler {
+    private String urlName;
+    private boolean contextMatchExact;
+    private NettyHttpDestination nettyHttpDestination;
+    private ServletContext servletContext;
+
+    public NettyHttpHandler(NettyHttpDestination nhd, boolean cmExact) {
+        contextMatchExact = cmExact;
+        nettyHttpDestination = nhd;
+    }
+
+    public void setServletContext(ServletContext sc) {
+        servletContext = sc;
+        if (nettyHttpDestination != null) {
+            nettyHttpDestination.setServletContext(sc);
+        }
+    }
+
+    public void setName(String name) {
+        urlName = name;
+    }
+
+    public String getName() {
+        return urlName;
+    }
+
+    boolean checkContextPath(String target) {
+        String pathString = urlName;
+        if (!pathString.endsWith("/")) {
+            pathString = pathString + "/";
+        }
+        return target.startsWith(pathString);
+    }
+
+    public void handle(String target, HttpServletRequest request,
+                       HttpServletResponse response) throws IOException, ServletException {
+        if (contextMatchExact) {
+            if (target.equals(urlName)) {
+                nettyHttpDestination.doService(servletContext, request, response);
+            }
+        } else {
+            if (target.equals(urlName) || checkContextPath(target)) {
+                nettyHttpDestination.doService(servletContext, request, response);
+            }
+        }
+
+    }
+
+    public String getContextPath() {
+        return servletContext.getContextPath();
+    }
+
+}