读懂tomact源码二:Connector

我对tomact的源码不了解,可以说基本不了解,看到一篇文章感觉挺好的,http://www.importnew.com/21112.html,分享下。

tomact有2个核心模块一个Connector和Container。我们今天说说Connector吧。

protocol

tomact中server的配置

<Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000"
           redirectPort="8443" />
<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

1
2
3

Connector类的代码片段

“`

/**
* Set the Coyote protocol which will be used by the connector.
*
* @param protocol The Coyote protocol name
*/
public void setProtocol(String protocol) {

if (AprLifecycleListener.isAprAvailable()) {
    if ("HTTP/1.1".equals(protocol)) {
        setProtocolHandlerClassName
            ("org.apache.coyote.http11.Http11AprProtocol");
    } else if ("AJP/1.3".equals(protocol)) {
        setProtocolHandlerClassName
            ("org.apache.coyote.ajp.AjpAprProtocol");
    } else if (protocol != null) {
        setProtocolHandlerClassName(protocol);
    } else {
        setProtocolHandlerClassName
            ("org.apache.coyote.http11.Http11AprProtocol");
    }
} else {
    if ("HTTP/1.1".equals(protocol)) {
        setProtocolHandlerClassName
            ("org.apache.coyote.http11.Http11Protocol");
    } else if ("AJP/1.3".equals(protocol)) {
        setProtocolHandlerClassName
            ("org.apache.coyote.ajp.AjpProtocol");
    } else if (protocol != null) {
        setProtocolHandlerClassName(protocol);
    }
}

}“`
我们可以看到org.apache.coyote.http11.Http11Protocol是默认的协议,这里我们也可以配置其他的吧。

ProtocolHandler

继承关系

这里写图片描述

到这里我们可以看到了server中配置的协议和ProtocolHandler的关系;页可以知道了server中,除了配置协议,也可以直接配置类的名字。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值