Based on Tomcat 5, this article also takes into account the latest Tomcat 6 and Tomcat 4. Tomcat's basic design ideas and architectures are of a certain continuity.
TOMCAT Overall structure
Tomcat's structure is very complex, but Tomcat is also very modular, and found the core of Tomcat module, you captured Tomcat's "seven". The following is the overall structure diagram of Tomcat:
Overall structure of Figure 1.Tomcat
As you can see from the image above, Tomcat's heart is two components: Connector and Container, which are described in detail later. The Connector component can be replaced so that it gives the server designer more choice, because this component is so important that it is not only relevant to the design of the server itself, but also to the different scenarios, so a Container can choose to correspond to multiple Connector. Multiple Connector and a Container on the formation of a service,service concept everyone is very familiar with the service can provide external services, but the service also needs a living environment, must have someone to give her life, master its health The death of power, that is not the Server mo. So the entire Tomcat lifecycle is controlled by the Server.
Service as a "marriage"
We compare Tomcat Connector, Container as a whole to a couple, Connector mainly responsible for external communication, can be likened to Boy, Container mainly deal with Connector accepted requests, mainly to deal with internal affairs, Can be likened to Girl. So this Service is to connect the men and women's marriage license. It is the Service that connects them together to form a family. Of course, it takes a lot of other elements to make up a family.
To put it bluntly, service is just a Connector and Container outside a layer, assembled them together, to provide services outside, a service can set up multiple Connector, but only one Container container. The list of methods for this Service interface is as follows:
Figure 2. Service interface