日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

tomcat Connector 连接器

發布時間:2023/12/18 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 tomcat Connector 连接器 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?

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

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 连接器的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。