Tomcat

187 阅读1分钟

1、各种组件

TomcatServletWebServerFactory的getWebServer方法:
	创建了Tomcat和Connector,给Tomcat设置baseDir;给Tomcat下面的Server里面的第
    一个Service设置Connector;给Tomcat设置Connector;
    	创建TomcatWebServer
TomcatWebServer的initialize方法:
	调用tomcat的start方法
Tomcat的start方法:
	创建一个Server;创建一个Service,
    并且调用server的start方法;
Server的startInternal方法:
	调用NamingResourcesImpl的start方法,调用service的start方法
Service的startInternal方法:
	调用engine的start方法;
    	调用executor的start方法;
    	调用mapperListener的start方法;
    	调用Connector的start方法;
Engine的start方法:
	调用ContainerBase的startInternal方法
Executor的startInternal方法:
	创建TaskQueue;
    创建ThreadPoolExecutor;
mapperListener的startInternal方法:
	给engine添加监听器;
    注册host;
Connector的startInternal方法:
	调用AbstractProtocol的start方法;
AbstractProtocol的start方法:
	调用AbstractEndPoint的start方法;
AbstractEndPoint的start方法:
	初始化ServerSocket;
    设置stopLatch;
    初始化ssl;
    调用NioSelectorPool的open方法
    NioEndPoint的startInternal方法:创建Executor;
    初始化LimitLatch;
    创建轮训器Poller,并且启动;
    创建接收器Acceptor,并启动;
轮训器-Poller的run方法:
	创建SocketProcessor,并且交给executor执行;
接收器-Acceptor的run方法:
	获取连接或者等待;
    接受来自服务器的套接字

2、

server的initInternal的方法:
	调用globalNamingResources的init方法;
    调用service的init方法;
service的init方法:
	调用Engine的init方法;
    调用executor的init方法;
    调用mapperListener的init方法;
    调用Connector的init方法;
Connector的init方法:
	初始化CoyoteAdapter;
    调用Protocol的init方法;