`
healthandbeauty
  • 浏览: 164818 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

netty

阅读更多

netty介绍:

Netty是由JBOSS提供的一个java开源框架。Netty提供异步的、事件驱动的网络应用程序框架和工具,用以快速开发高性能、高可靠性的网络服务器客户端程序。

 

测试类

public abstract class ClientToServerTest extends TestCase {
    
    protected static final String LOCALHOST = "127.0.0.1";
    
    protected ExchangeServer server;
    
    protected ExchangeChannel client;
    
    protected WorldHandler handler = new WorldHandler();
    
    protected abstract ExchangeServer newServer(int port, Replier<?> receiver) throws RemotingException;
    
    protected abstract ExchangeChannel newClient(int port) throws RemotingException;
    
    @Override
    protected void setUp() throws Exception {
        super.setUp();
        int port = (int) (1000 * Math.random() + 10000);
        server = newServer(port, handler);
        client = newClient(port);
    }

    @Override
    protected void tearDown() throws Exception {
        super.tearDown();
        try {
            if (server != null)
                server.close();
        } finally {
            if (client != null)
                client.close();
        }
    }

    @Test
    public void testFuture() throws Exception {
        ResponseFuture future = client.request(new World("world"));
        Hello result = (Hello)future.get();
        System.out.println(result.getName()+" hello world");
        Assert.assertEquals("hello,world", result.getName());
    }
}

 Handle处理类

写道
public class WorldHandler implements Replier<World> {

public Class<World> interest() {
return World.class;
}

public Object reply(ExchangeChannel channel, World msg) throws RemotingException {
return new Hello("hello," + msg.getName());
}

}

 NettyClientToServerTest类

写道
public class NettyClientToServerTest extends ClientToServerTest {

protected ExchangeServer newServer(int port, Replier<?> receiver) throws RemotingException {
return Exchangers.bind(URL.valueOf("exchange://localhost:" + port + "?server=netty"), receiver);
}

protected ExchangeChannel newClient(int port) throws RemotingException {
return Exchangers.connect(URL.valueOf("exchange://localhost:" + port + "?client=netty"));
}

}

 

分享到:
评论
1 楼 kamismile 2013-04-15  
                 

相关推荐

    Netty (netty-netty-4.0.56.Final.tar.gz)

    Netty (netty-netty-4.0.56.Final.tar.gz)是一个 NIO 客户端服务器框架,可以快速轻松地开发协议服务器和客户端等网络应用程序。它极大地简化和流线了网络编程,例如 TCP 和 UDP 套接字服务器。 “快速和简单”并...

    Netty (netty-netty-5.0.0.Alpha2.tar.gz)

    Netty (netty-netty-5.0.0.Alpha2.tar.gz)是一个 NIO 客户端服务器框架,可以快速轻松地开发协议服务器和客户端等网络应用程序。它极大地简化和流线了网络编程,例如 TCP 和 UDP 套接字服务器。 “快速和简单”并...

    netty-netty-3.10.6.Final.tar.gz

    Netty (netty-netty-3.10.6.Final.tar.gz)是一个 NIO 客户端服务器框架,可以快速轻松地开发协议服务器和客户端等网络应用程序。它极大地简化和流线了网络编程,例如 TCP 和 UDP 套接字服务器。 “快速和简单”并...

    netty-all-4.1.32.Final-sources.jar 最新版netty源码全部包

    netty-buffer-4.1.32.Final-sources.jar netty-buffer-4.1.32.Final.jar netty-build-22-sources.jar netty-build-22.jar netty-codec-4.1.32.Final-sources.jar netty-codec-4.1.32.Final.jar netty-codec-...

    netty-all-4.1.29.Final-sources.jar 最新版netty源码

    本jar包为最新的netty-all-4.1.29c.jar 可导入直接用 Netty 是一个利用 Java 的高级网络的能力,隐藏其背后的复杂性而提供一个易于使用的 API 的客户端/服务器框架。 Netty 是一个广泛使用的 Java 网络编程框架...

    netty-all-4.1.17.Final-API文档-中文版.zip

    赠送jar包:netty-all-4.1.17.Final.jar; 赠送原API文档:netty-all-4.1.17.Final-javadoc.jar; 赠送源代码:netty-all-4.1.17.Final-sources.jar; 赠送Maven依赖信息文件:netty-all-4.1.17.Final.pom; 包含...

    netty-all-4.1.27.Final-API文档-中文版.zip

    赠送jar包:netty-all-4.1.27.Final.jar; 赠送原API文档:netty-all-4.1.27.Final-javadoc.jar; 赠送源代码:netty-all-4.1.27.Final-sources.jar; 赠送Maven依赖信息文件:netty-all-4.1.27.Final.pom; 包含...

    reactor-netty-core-1.0.15-API文档-中文版.zip

    赠送jar包:reactor-netty-core-1.0.15.jar; 赠送原API文档:reactor-netty-core-1.0.15-javadoc.jar; 赠送源代码:reactor-netty-core-1.0.15-sources.jar; 赠送Maven依赖信息文件:reactor-netty-core-1.0.15....

    netty-all-4.1.97.Final-20230731.020124-2.jar netty最新jar包,可直接导入使用

    Netty 是一个利用 Java 的高级网络的能力,隐藏其背后的复杂性而提供一个易于使用的 API 的客户端/服务器框架。 Netty 是一个广泛使用的 Java 网络编程框架(Netty 在 2011 年获得了Duke's Choice Award,见...

    netty-3.10.5.Final-API文档-中文版.zip

    赠送jar包:netty-3.10.5.Final.jar; 赠送原API文档:netty-3.10.5.Final-javadoc.jar; 赠送源代码:netty-3.10.5.Final-sources.jar; 赠送Maven依赖信息文件:netty-3.10.5.Final.pom; 包含翻译后的API文档:...

    netty-codec-mqtt-4.1.73.Final-API文档-中文版.zip

    赠送jar包:netty-codec-mqtt-4.1.73.Final.jar; 赠送原API文档:netty-codec-mqtt-4.1.73.Final-javadoc.jar; 赠送源代码:netty-codec-mqtt-4.1.73.Final-sources.jar; 赠送Maven依赖信息文件:netty-codec-...

    springboot整合 netty做心跳检测

    springboot整合 netty做心跳检测 springboot整合 netty做心跳检测 springboot整合 netty做心跳检测 springboot整合 netty做心跳检测 springboot整合 netty做心跳检测 springboot整合 netty做心跳检测 springboot整合...

    netty-all-4.1.22.Final.jar netty最新版jar包,直接导入

    Netty is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients. Netty is a NIO client server framework which ...

    NettyAndroid,Netty在Android中的使用

    Netty在Android开发中的应用实战系列(一)——— 搭建服务端与客户端:https://azhon.blog.csdn.net/article/details/100569489 Netty在Android开发中的应用实战系列(二)——— Encoder | Decoder | Handler 的...

    reactor-netty-http-1.0.11-API文档-中文版.zip

    赠送jar包:reactor-netty-http-1.0.11.jar; 赠送原API文档:reactor-netty-http-1.0.11-javadoc.jar; 赠送源代码:reactor-netty-http-1.0.11-sources.jar; 赠送Maven依赖信息文件:reactor-netty-...

    netty-all-4.1.10.Final.jar netty最新版jar包,直接导入

    Netty is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients. Netty is a NIO client server framework which ...

    netty-all-4.1.68.Final-API文档-中英对照版.zip

    赠送jar包:netty-all-4.1.68.Final.jar; 赠送原API文档:netty-all-4.1.68.Final-javadoc.jar; 赠送源代码:netty-all-4.1.68.Final-sources.jar; 赠送Maven依赖信息文件:netty-all-4.1.68.Final.pom; 包含...

    netty-transport-rxtx-4.1.74.Final-API文档-中文版.zip

    赠送jar包:netty-transport-rxtx-4.1.74.Final.jar; 赠送原API文档:netty-transport-rxtx-4.1.74.Final-javadoc.jar; 赠送源代码:netty-transport-rxtx-4.1.74.Final-sources.jar; 赠送Maven依赖信息文件:...

    netty权威指南 第1版(李林峰) + 源码

    《Netty权威指南》第1版 是异步非阻塞通信领域的经典之作,基于最新版本Netty 5.0编写,是国内首本深入介绍Netty原理和架构的技术书籍,也是作者多年实战经验的总结和浓缩。在理论方面,讲解了Netty的逻辑架构模型和...

    netty-common-4.1.68.Final-API文档-中文版.zip

    赠送jar包:netty-common-4.1.68.Final.jar; 赠送原API文档:netty-common-4.1.68.Final-javadoc.jar; 赠送源代码:netty-common-4.1.68.Final-sources.jar; 赠送Maven依赖信息文件:netty-common-4.1.68.Final....

Global site tag (gtag.js) - Google Analytics