Tomcat source code analysis

Source: Internet
Author: User
Tags wrappers

Tomcat source code analysis

Tomcat is composed of multiple containers, and the Container and Connecter connector are the two core modules of Tomcat. The Connecter connector receives client requests, then, it passes the request from the client to the Container for processing and responds accordingly.

Tomcat has multiple levels of container objects: Engine, Host, Context, and Wrapper. These containers are hierarchical.

  • Engine: The Servlet Engine of Tomcat. It can contain one or more sub-containers.
  • Host: indicates a virtual Host that contains multiple Context
  • Context: indicates a ServletContext, which contains one or more Wrappers containers.
  • Wrappers: indicates an independent Servlet definition. It can be multiple servlets or one servlet instance.

All containers inherit the inerbase abstract class, And the inerbase abstract class implements the Container interface. The Container inherits the Lifecycle interface for unified management of the Container Lifecycle.

The Container interface defines static fields to indicate the event types when a sub-Container is added or removed (for example ):

The following figure shows the class structure of ContainerBase. Due to the limited space, the fields and methods of interfaces and classes are not listed here:

ContainerBase class diagram

1. Lifecycle interface: defines the interface used to control the Lifecycle of all Tomcat components. 2. LifecycleBase abstract class: implements the Lifecycle interface for managing the Lifecycle of all Tomcat components. 3. MBeanRegistration interface: Used to enable Tomcat to support interfaces defined by JMX. 4. LifecycleMBeanBase abstract class: inherits LifecycleBase and implements the MBeanRegistration interface to support JMX. 5. Container interface: it is the interface of all our containers. It defines the common fields of containers and methods. 6. ContainerBase abstract class: The base class of all containers, which implements some sub-container management methods (add, remove, and search ), sub-containers are started to manage container event listening objects, including the management of Loader, Logger, Manager, Realm, and Resources components, and the management of Pipeline and Valve objects.

The following figure shows all Tomcat containers (fields and methods are omitted ):

 

Container class diagram

 

This section analyzes each container in Tomcat in detail.

For more Tomcat tutorials, see the following:

Install and configure the Tomcat environment in CentOS 6.6

Install JDK + Tomcat in RedHat Linux 5.5 and deploy Java Projects

Tomcat authoritative guide (second edition) (Chinese/English hd pdf + bookmarks)

Tomcat Security Configuration and Performance Optimization

How to Use Xshell to view Tomcat real-time logs with Chinese garbled characters in Linux

Install JDK and Tomcat in CentOS 64-bit and set the Tomcat Startup Procedure

Install Tomcat in CentOS 6.5

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • 3
  • Next Page
[Content navigation]
Page 7: overall container structure Page 2nd: component startup Implementation Analysis
Page 3rd: analysis of the specific Startup Process

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.