1. Bootstrap:start()------
初始化:設定catalinaHome,catalinaBase, 初始化classLoader(commonLoader,sharedLoader,catalinaLoader).
通過反射Catalina.class 調用其方法setParentClassLoader。
2 ---------->Catalina.class start()--------
load():初始化dirs,naming,digester,initStreams,
3 ----->StandardService.start()--------
init() :Container,Register with the server ,Initialize our defined Connectors(Initializa adapter,)------
4 ----->connector: start()------
Initialize our defined Connectors(Initializa adapter,)
registerComponent--protocolHandler----
// Initializa adapter
adapter = new CoyoteAdapter(this);
protocolHandler.setAdapter(adapter);
adapter通過protocolHandler(Http11Protocol)傳給Http11Processor,
Http11Processor解析,create request和response,通過adapter傳送給Container
5 ------>protocolHandler.start()------
6 ------>Http11Protocol.class .start()------
7 ----->JIoEndpoint JIoEndpoint.start(); JioEndpoint啟動server Socket,listern 8080端口,處理http請求
http://localhost:8080/wsota/wsota_index.jsp
1) 請求被發送到本機端口8080,被在那裡偵聽的Coyote HTTP/1.1 Connector獲得
2) Connector把該請求交給它所在的Service的Engine來處理,并等待來自Engine的回應
3) Engine獲得請求localhost/wsota/wsota_index.jsp,比對它所擁有的所有虛拟主機Host
4) Engine比對到名為localhost的Host(即使比對不到也把請求交給該Host處理,因為該Host被定義為該Engine的預設主機)
5) localhost Host獲得請求/wsota/wsota_index.jsp,比對它所擁有的所有Context
6) Host比對到路徑為/wsota的Context(如果比對不到就把該請求交給路徑名為""的Context去處理)
7) path="/wsota"的Context獲得請求/wsota_index.jsp,在它的mapping table中尋找對應的servlet
8) Context比對到URL PATTERN為*.jsp的servlet,對應于JspServlet類
9) 構造HttpServletRequest對象和HttpServletResponse對象,作為參數調用JspServlet的doGet或doPost方法
10)Context把執行完了之後的HttpServletResponse對象傳回給Host
11)Host把HttpServletResponse對象傳回給Engine
12)Engine把HttpServletResponse對象傳回給Connector
13)Connector把HttpServletResponse對象傳回給客戶browser