文档库 最新最全的文档下载
当前位置:文档库 › Netty中文 API文档

Netty中文 API文档

Netty中文 API文档
Netty中文 API文档

https://www.wendangku.net/doc/b52766747.html,ty.bootstrap

Bootstrap : ChannelFactory, ChannelPipeline, ChannelPipelineFactory 初始化channel的辅助类

为具体的子类提供公共数据结构

ServerBootstrap: bind()

创建服务器端channel的辅助类

接收connection请求

ClientBootstrap: connect()

创建客户端channel的辅助类发起connection请求ConnectionlessBootstrap: connect() , bind()

创建无连接传输channel的辅助类(UDP)

包括Client 和Server

https://www.wendangku.net/doc/b52766747.html,ty.buffer

取代nio中的java.nio.ByteBuffer,相比ByteBuffer

可以根据需要自定义buffer type

内置混合的buffer type, 以实现zero-copy

提供类似StringBuffer的动态dynamic buffer

不需要调用flip方法

更快的性能

推荐使用ChannelBuffers的静态工厂创建ChannelBuffer

https://www.wendangku.net/doc/b52766747.html,ty.channel

channel核心api,包括异步和事件驱动等各种传送接口https://www.wendangku.net/doc/b52766747.html,ty.channel.group

channel group,帮助用户维护channel列表

https://www.wendangku.net/doc/b52766747.html,ty.channel.local

一种虚拟传输方式,允许同一个虚拟机上的两个部分可以互相通信https://www.wendangku.net/doc/b52766747.html,ty.channel.socket

TCP, UDP接口,继承了核心的channel API

https://www.wendangku.net/doc/b52766747.html,ty.channel.socket.nio

基于nio的Socket channel实现

https://www.wendangku.net/doc/b52766747.html,ty.channel.socket.oio

基于老io的Socket channel实现

https://www.wendangku.net/doc/b52766747.html,ty.channel.socket.http

基于http的客户端和相应的server端的实现,工作在有防火墙的情况https://www.wendangku.net/doc/b52766747.html,ty.container

各种容器的兼容

https://www.wendangku.net/doc/b52766747.html,ty.container.microcontainer JBoss Microcontainer集成接口https://www.wendangku.net/doc/b52766747.html,ty.container.osgi

OSGiframework集成接口

https://www.wendangku.net/doc/b52766747.html,ty.container.spring

Spring framework集成接口

https://www.wendangku.net/doc/b52766747.html,ty.handler

处理器

https://www.wendangku.net/doc/b52766747.html,ty.handler.codec

编码解码器

https://www.wendangku.net/doc/b52766747.html,ty.handler.execution

基于Executor的实现

https://www.wendangku.net/doc/b52766747.html,ty.handler.queue

将event存入内部队列的处理

https://www.wendangku.net/doc/b52766747.html,ty.handler.ssl

基于SSLEngine的SSL以及TLS实现

https://www.wendangku.net/doc/b52766747.html,ty.handler.stream

异步写入大数据,不会产生outOfMemory也不会花费很多内存https://www.wendangku.net/doc/b52766747.html,ty.handler.timeout

通过Timer来对读写超时或者闲置链接进行通知

https://www.wendangku.net/doc/b52766747.html,ty.handler.codec.base64

Base64 编码

https://www.wendangku.net/doc/b52766747.html,pression

压缩格式

https://www.wendangku.net/doc/b52766747.html,ty.handler.codec.embedder

嵌入模式下编码和解码

https://www.wendangku.net/doc/b52766747.html,ty.handler.codec.frame

评估流的数据的排列和内容

https://www.wendangku.net/doc/b52766747.html,ty.handler.codec.http.websocket websocket编码解码

https://www.wendangku.net/doc/b52766747.html,ty.handler.codec.http

http的编码解码以及类型信息

https://www.wendangku.net/doc/b52766747.html,ty.handler.codec.oneone

对象到对象编码解码

https://www.wendangku.net/doc/b52766747.html,ty.handler.codec.protobuf

Protocol Buffers的编码解码

https://www.wendangku.net/doc/b52766747.html,ty.handler.codec.replay

在阻塞io中实现非阻塞解码

https://www.wendangku.net/doc/b52766747.html,ty.handler.codec.rtsp

RTSP的编码解码

https://www.wendangku.net/doc/b52766747.html,ty.handler.codec.serialization 序列化对象到bytebuffer实现

https://www.wendangku.net/doc/b52766747.html,ty.handler.codec.string

字符串编码解码,继承oneone https://www.wendangku.net/doc/b52766747.html,ty.logging

根据不同的log framework 实现的类https://www.wendangku.net/doc/b52766747.html,ty.util

Netty util类

https://www.wendangku.net/doc/b52766747.html,ty.util.internal

netty内部util类,不被外部使用

Netty事件驱动模型

Upstream接收请求

Downstream发送请求

ChannelPipelinep = Channels.pipeline();

p.addLast("1", new UpstreamHandlerA());

p.addLast("2", new UpstreamHandlerB());

p.addLast("3", new DownstreamHandlerA());

p.addLast("4", new DownstreamHandlerB());

p.addLast("5", new UpstreamHandlerX());

Upstream: 1 →2 →5 顺序处理

Downstream: 4 →3 逆序处理

connect

bind

write

close

disconnect

unbind

isOpen

isBound isConnected isReadable

isWritable

NettyZero-Copy-Capable Buffer

序列访问索引

+-----------------------+---------------------+--------------------+ | discardablebytes| readable bytes | writable bytes | +-----------------------+---------------------+--------------------+ | | | | 0 <= readerIndex<= writerIndex<= capacity

get & set :not modify the readerIndexor writerIndex read & write : modify the readerIndexor writerIndex

NettyZero-Copy-Capable Buffer

ChannelBuffer

–定义接口

ChannelBuffers

–静态工厂

–隐藏具体类型

Netty数据流分析服务器启动

服务器主通道监听服务器子通道开通客户端启动

客户端主通道监听客户端子通道开通

Netty API

相关文档