连接器的核心功能,本文去除非核心功能,留下整个程序的框架,便于理解。

1、接受连接请求

2.创建request,和response.

3.调用容器对应的Invoke方法,

首先看类的依赖结构。

1.Connetor 构造方法,根据具体的协议名字,创建协议处理器,主要有NIO,BIO,AJP,协议。如果要自定义协议处理剂最重要的协议处理器了。如图,协议处理需要实现ProtocoHandler接口,

构造函数 输入为协议名称

 public Connector(String protocol) {setProtocol(protocol);// Instantiate protocol handlerProtocolHandler p = null;try {Class<?> clazz = Class.forName(protocolHandlerClassName);           // 实例化一个协议处理器p = (ProtocolHandler) clazz.newInstance();} catch (Exception e) {log.error(sm.getString("coyoteConnector.protocolHandlerInstantiationFailed"), e);} finally {this.protocolHandler = p;}if (!Globals.STRICT_SERVLET_COMPLIANCE) {URIEncoding = "UTF-8";URIEncodingLower = URIEncoding.toLowerCase(Locale.ENGLISH);}}

2.createRequest 和相应  此处不仔细深入。很简单。就是创建请求和相应对象

 public Request createRequest() {Request request = new Request();request.setConnector(this);return (request);}/*** Create (or allocate) and return a Response object suitable for* receiving the contents of a Response from the responsible Container.*/public Response createResponse() {Response response = new Response();response.setConnector(this);return (response);}

3.启动和关闭。是默认方法;

protected void startInternal() throws LifecycleException {// Validate settings before startingif (getPort() < 0) {throw new LifecycleException(sm.getString("coyoteConnector.invalidPort", Integer.valueOf(getPort())));}setState(LifecycleState.STARTING);try {protocolHandler.start();} catch (Exception e) {String errPrefix = "";if(this.service != null) {errPrefix += "service.getName(): \"" + this.service.getName() + "\"; ";}throw new LifecycleException(errPrefix + " " + sm.getString("coyoteConnector.protocolHandlerStartFailed"), e);}}

protected void stopInternal() throws LifecycleException {

setState(LifecycleState.STOPPING);

try {
protocolHandler.stop();
} catch (Exception e) {
throw new LifecycleException
(sm.getString
("coyoteConnector.protocolHandlerStopFailed"), e);
}
}

 

我们从代码看到ProtocoHandler的重要性了明天再看

转载于:https://www.cnblogs.com/hansongjiang/p/4194300.html

tomcat Connector 连接器相关推荐

  1. 《How Tomcat Works》读书笔记(三)--Connector(连接器)

    <How Tomcat Works>读书笔记(三)--Connector(连接器) 这是<How Tomcat Works>第三四章的读书笔记.主要写了Tomcat4.0默认的 ...

  2. tomcat(3)连接器

    [0]README 0.1)本文部分内容转自"深入剖析tomcat",旨在学习 tomcat(3)连接器 的基础知识: 0.2)Catalina 中有两个主要的模块:连接器(Ser ...

  3. 修改Tomcat Connector运行模式,优化Tomcat运行性能

    这篇博客写得很好,记下来了:http://www.cnblogs.com/freeweb/p/6430053.html http://blog.csdn.net/xyang81/article/det ...

  4. 【Tomcat】Tomcat Connector的三种运行模式【bio、nio、apr】

    Tomcat Connector(Tomcat连接器)有bio.nio.apr三种运行模式 bio bio(blocking I/O,阻塞式I/O操作),表示Tomcat使用的是传统的Java I/O ...

  5. Tomcat Connector的三种运行模式【bio、nio、apr】

    Tomcat Connector(Tomcat连接器)有bio.nio.apr三种运行模式 bio bio(blocking I/O,阻塞式I/O操作),表示Tomcat使用的是传统的Java I/O ...

  6. 大厂面试真题解读:Tomcat的连接器是如何设计的?

    导读 为什么要学习Tomcat的设计思路,对我们这些 crud 工程师有用吗?现代背景下,我们不仅可以学到Tomcat的架构,学会从宏观上怎么去设计一个复杂系统,怎么设计顶层模块,以及模块之间关系. ...

  7. 8080:The Tomcat connector configured to listen on port 8080 failed to start 的解决办法

    问题再现: 控制台最后会显示Application启动失败,如下: ...*************************** APPLICATION FAILED TO START ******* ...

  8. Tomcat Connector

    Tomcat是最常用的web容器之一,Tomcat Connector有bio.nio.apr三种运行模式: Tomcat运行模式: bio bio(blocking I/O),顾名思义,即阻塞式I/ ...

  9. httpd +jk_虚拟主机+ Apache httpd服务器+ Tomcat + mod_jk连接器

    httpd +jk 在上一篇文章( Tomcat中的虚拟主机 )中,我们讨论了如何在Tomcat中设置虚拟主机. 它具有成本效益,因为仅一个公共IP即可托管多个域. 如果我们有大型组织,并且每个部门都 ...

最新文章

  1. ipython notebook_50个关于IPython的使用技巧,get起来!
  2. C#中Encoding.Unicode与Encoding.UTF8的区别
  3. mysql dump 查看器_mysql备份之mysqldump工具
  4. C#字符串截取学习总结
  5. Android --- RecycleView获取第 i 个 item 里面的控件并进行赋值
  6. java jsp公共异常页面_实际应用中JSP页面的异常处理
  7. Python笔记-UiSelector混合定位
  8. 装饰者模式-继承模式和接口模式
  9. Android 系统自带的图标
  10. python爬取豆瓣电影排行榜_爬取豆瓣电影排名的代码以及思路
  11. MyEclipse或Eclipse中工程的导入和导出
  12. 2021-06-16单例模式详解
  13. mybatis操作mysql的奇淫技巧总结(代码库)
  14. 爬取东方财富的利润表数据记录
  15. Scrapy-spiders下项目运行方法
  16. 企业用免费邮箱哪个好
  17. Canvas 指纹图片改成红色
  18. python的requests.get()方法获取百度搜索结果页面失败的问题
  19. 微众银行客服电话是95384 认准官方的人工客服电话
  20. 【网易笔试】小易最近在数学课上学习到了集合的概念

热门文章

  1. python概念英文版_python重要概念
  2. date类before()方法的主要作用是_DateFormat类的子类:SimpleDateFormat
  3. python挂机脚本阴阳师_Python简单实现阴阳师挂机脚本
  4. 1、程序员常用工具网站
  5. ue4材质节点怎么用_济南装修:阳台储物柜用什么材质好?怎么保养阳台储物柜?...
  6. 联想e52进入bios_联想笔记本怎么设置u盘启动|联想笔记本bios设置usb启动步骤
  7. 一维有限元法matlab,一维有限元法解常微分方程
  8. jq中查找上级_必备实用技能:在EXCEL中制作下拉菜单
  9. jvm对于java的意义_谈谈对JVM的理解
  10. 「猜题第一篇」2019年大学生电子设计竞赛