1.概述
Dubbo 的 HTTP 服务器,在 dubbo-remoting-http 模块中实现,使用在 http://、 rest://、hessian://、webservice://协议上。
dubbo-remoting-http 模块,类图如下:

2.API
2.1 HttpServer
实现 Resetable 接口,HTTP 服务器接口。方法如下:
/**
* HTTP 服务器接口
*/
public interface HttpServer extends Resetable {
/**
* get http handler.
*
* @return http handler.
*/
HttpHandler getHttpHandler();
/**
* get url.
*
* @return url
*/
URL getUrl();
/**
* get local address.
*
* @return local address.
*/
InetSocketAddress getLocalAddress();
/**
* close the channel.
*/
void close();
/**
* Graceful close the channel.
*/
void close(int timeout);
/**
* is bound.
*
* @return bound
*/
boolean isBound();
/**
* is closed.
*
* @return closed
*/
boolean isClosed();
}
2.2 AbstractHttpServer
实现 HttpServer 接口,HTTP 服务器抽象类。代码如下:
/**
* AbstractHttpServer
*
* HTTP 服务器抽象类
*/
public abstract class AbstractHttpServer implements HttpServer {
/**
* URL 对象
*/
private final URL url;
/**
* 处理器
*/
private final HttpHandler handler;
/**
* 是否关闭
*/
private volatile boolean closed;
public AbstractHttpServer(URL url, HttpHandler handler) {
if (url == null) {
throw new IllegalArgumentException("url == null");
}
if (hand

本文深入剖析Dubbo的HTTP服务器,从API层面介绍HttpServer、AbstractHttpServer、HttpHandler、HttpBinder、DispatcherServlet和ServletManager,并详细讲解基于Tomcat的实现TomcatHttpServer。
最低0.47元/天 解锁文章
540

被折叠的 条评论
为什么被折叠?



