* Reorganized HTTP examples (will add file server example later)
* Fixed configuration errors in the HTTP tunneling transport example
This commit is contained in:
parent
b19d488312
commit
f9c38bb76b
@ -19,7 +19,7 @@
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
||||
*/
|
||||
package org.jboss.netty.example.http;
|
||||
package org.jboss.netty.example.http.snoop;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
@ -19,7 +19,7 @@
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
||||
*/
|
||||
package org.jboss.netty.example.http;
|
||||
package org.jboss.netty.example.http.snoop;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
@ -19,7 +19,7 @@
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
||||
*/
|
||||
package org.jboss.netty.example.http;
|
||||
package org.jboss.netty.example.http.snoop;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
@ -19,7 +19,7 @@
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
||||
*/
|
||||
package org.jboss.netty.example.http;
|
||||
package org.jboss.netty.example.http.snoop;
|
||||
|
||||
import org.jboss.netty.buffer.ChannelBuffer;
|
||||
import org.jboss.netty.channel.ChannelHandlerContext;
|
@ -19,7 +19,7 @@
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
||||
*/
|
||||
package org.jboss.netty.example.http;
|
||||
package org.jboss.netty.example.http.snoop;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.concurrent.Executors;
|
@ -19,7 +19,7 @@
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
||||
*/
|
||||
package org.jboss.netty.example.http;
|
||||
package org.jboss.netty.example.http.snoop;
|
||||
|
||||
import static org.jboss.netty.channel.Channels.*;
|
||||
|
@ -19,7 +19,7 @@
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
||||
*/
|
||||
package org.jboss.netty.example.http;
|
||||
package org.jboss.netty.example.http.tunnel;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
@ -33,65 +33,73 @@ import org.jboss.netty.channel.ChannelHandlerContext;
|
||||
import org.jboss.netty.channel.ChannelPipelineCoverage;
|
||||
import org.jboss.netty.channel.socket.http.HttpTunnelAddress;
|
||||
import org.jboss.netty.channel.socket.http.HttpTunnelingClientSocketChannelFactory;
|
||||
import org.jboss.netty.channel.socket.http.HttpTunnelingServlet;
|
||||
import org.jboss.netty.channel.socket.oio.OioClientSocketChannelFactory;
|
||||
import org.jboss.netty.handler.codec.oneone.OneToOneDecoder;
|
||||
import org.jboss.netty.handler.codec.string.StringDecoder;
|
||||
import org.jboss.netty.handler.codec.string.StringEncoder;
|
||||
|
||||
/**
|
||||
* make sure that the LocalTransportRegister bean is deployed along with the NettyServlet with the following web.xml
|
||||
* Make sure that the {@link LocalTransportRegister} bean is deployed along
|
||||
* with the {@link HttpTunnelingServlet} with the following <tt>web.xml</tt>.
|
||||
*
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<web-app xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
|
||||
version="2.4">
|
||||
<!--the name of the channel, this should be a registered local channel. see LocalTransportRegister-->
|
||||
<context-param>
|
||||
<param-name>serverChannelName</param-name>
|
||||
<param-value>org.jboss.netty.exampleChannel</param-value>
|
||||
</context-param>
|
||||
|
||||
<!--Whether or not we are streaming or just polling using normal http requests-->
|
||||
<context-param>
|
||||
<param-name>streaming</param-name>
|
||||
<param-value>true</param-value>
|
||||
</context-param>
|
||||
|
||||
<!--how long to wait for a client reconnecting in milliseconds-->
|
||||
<context-param>
|
||||
<param-name>reconnectTimeout</param-name>
|
||||
<param-value>3000</param-value>
|
||||
</context-param>
|
||||
|
||||
<listener>
|
||||
<listener-class>org.jboss.netty.servlet.NettySessionListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<listener>
|
||||
<listener-class>org.jboss.netty.servlet.NettyServletContextListener</listener-class>
|
||||
</listener>
|
||||
|
||||
<servlet>
|
||||
<servlet-name>NettyServlet</servlet-name>
|
||||
<servlet-class>org.jboss.netty.servlet.NettyServlet</servlet-class>
|
||||
</servlet>
|
||||
|
||||
<servlet-mapping>
|
||||
<servlet-name>NettyServlet</servlet-name>
|
||||
<url-pattern>/nettyServlet</url-pattern>
|
||||
</servlet-mapping>
|
||||
</web-app>
|
||||
|
||||
* <pre>
|
||||
* <?xml version="1.0" encoding="UTF-8"?>
|
||||
* <web-app xmlns="http://java.sun.com/xml/ns/j2ee"
|
||||
* xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
* xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"
|
||||
* version="2.4">
|
||||
* <!--the name of the channel, this should be a registered local channel. see LocalTransportRegister-->
|
||||
* <context-param>
|
||||
* <param-name>serverChannelName</param-name>
|
||||
* <param-value>myLocalServer</param-value>
|
||||
* </context-param>
|
||||
*
|
||||
* <!--Whether or not we are streaming or just polling using normal HTTP requests-->
|
||||
* <context-param>
|
||||
* <param-name>streaming</param-name>
|
||||
* <param-value>true</param-value>
|
||||
* </context-param>
|
||||
*
|
||||
* <!--How long to wait for a client reconnecting in milliseconds-->
|
||||
* <context-param>
|
||||
* <param-name>reconnectTimeout</param-name>
|
||||
* <param-value>3000</param-value>
|
||||
* </context-param>
|
||||
*
|
||||
* <listener>
|
||||
* <listener-class>org.jboss.netty.channel.socket.http.HttpTunnelingSessionListener</listener-class>
|
||||
* </listener>
|
||||
*
|
||||
* <listener>
|
||||
* <listener-class>org.jboss.netty.channel.socket.http.HttpTunnelingContextListener</listener-class>
|
||||
* </listener>
|
||||
*
|
||||
* <servlet>
|
||||
* <servlet-name>NettyTunnelingServlet</servlet-name>
|
||||
* <servlet-class>org.jboss.netty.channel.socket.http.HttpTunnelingServlet</servlet-class>
|
||||
* </servlet>
|
||||
*
|
||||
* <servlet-mapping>
|
||||
* <servlet-name>NettyTunnelingServlet</servlet-name>
|
||||
* <url-pattern>/netty-tunnel</url-pattern>
|
||||
* </servlet-mapping>
|
||||
* </web-app>
|
||||
* </pre>
|
||||
* @author The Netty Project (netty-dev@lists.jboss.org)
|
||||
* @author Andy Taylor (andy.taylor@jboss.org)
|
||||
* @version $Rev$, $Date$
|
||||
*/
|
||||
public class HttpTunnelingClientExample {
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
if (args.length != 1) {
|
||||
System.err.println(
|
||||
"Usage: " + HttpClient.class.getSimpleName() +
|
||||
"Usage: " + HttpTunnelingClientExample.class.getSimpleName() +
|
||||
" <URL>");
|
||||
System.err.println(
|
||||
"Example: " + HttpTunnelingClientExample.class.getSimpleName() +
|
||||
" http://localhost:8080/netty-tunnel");
|
||||
return;
|
||||
}
|
||||
|
@ -19,7 +19,7 @@
|
||||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
|
||||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
|
||||
*/
|
||||
package org.jboss.netty.example.http;
|
||||
package org.jboss.netty.example.http.tunnel;
|
||||
|
||||
import org.jboss.netty.bootstrap.ServerBootstrap;
|
||||
import org.jboss.netty.channel.Channel;
|
||||
@ -29,10 +29,12 @@ import org.jboss.netty.channel.local.LocalAddress;
|
||||
import org.jboss.netty.example.echo.EchoHandler;
|
||||
|
||||
/**
|
||||
* you can deploy this in jboss 5 by adding the following bean.
|
||||
* Deploy this in JBossAS 5 by adding the following bean.
|
||||
*
|
||||
* <bean name="org.jboss.netty.example.servlet.LocalTransportRegister"
|
||||
class="org.jboss.netty.example.servlet.LocalTransportRegister" />
|
||||
* <pre>
|
||||
* <bean name="org.jboss.netty.example.http.tunnel.LocalTransportRegister"
|
||||
* class="org.jboss.netty.example.http.tunnel.LocalTransportRegister" />
|
||||
* </pre>
|
||||
*
|
||||
* @author The Netty Project (netty-dev@lists.jboss.org)
|
||||
* @author Andy Taylor (andy.taylor@jboss.org)
|
||||
@ -47,7 +49,7 @@ public class LocalTransportRegister {
|
||||
ServerBootstrap serverBootstrap = new ServerBootstrap(factory);
|
||||
EchoHandler handler = new EchoHandler();
|
||||
serverBootstrap.getPipeline().addLast("handler", handler);
|
||||
serverChannel = serverBootstrap.bind(new LocalAddress("localAddress"));
|
||||
serverChannel = serverBootstrap.bind(new LocalAddress("myLocalServer"));
|
||||
}
|
||||
|
||||
public void stop() {
|
Loading…
x
Reference in New Issue
Block a user