Tomcat Launcher (ii) ORG.APACHE.CATALINA.STARTUP.BOOTSTRAP analysis

Source: Internet
Author: User
Tags xml parser

/** * Bootstrap loader for Catalina.  This application constructs a class loader * for use with loading the Catalina internal classes (by accumulating all of the * JAR files found in the "server" directory under "Catalina.home"), and * starts the regular execution of the container.
    the purpose of this * roundabout approach are to keep the Catalina internal classes (and any * other classes they depend On, such as a XML parser) out of the system * class path and therefore not visible to application level classes.

This class constructs a classloader to load Catalina internal classes (by Catalina.home in the server directory to find all the jar files), and starts to execute container containers on a regular basis.

The purpose of this maneuver is to keep the Catalina inner class (and any other classes it relies on, such as an XML parser) out of the system classpath, so it is not visible to the application level

Entrance Main method

Perform static static module code before entering main: mainly to set the path of Catalina.home and Catalina.base

public static void Main (String args[]) {
Bootstrap init initialization ()
Set Daemon daemon = bootstrap;
Identify parameters to be passed when starting bootstrap command = Args[args.length-1];//start
Daemon.setawait (TRUE);
Daemon.load (args);
Daemon.start ();}

The method above Damemon daemon setawait (), load (), start () is actually a method of reflection called Org.apache.catalina.startup.Catalina class

In fact, into the Catalina class.

--------------------------Bootstrap class parsing is complete------The following is an explanation of the Init method---------------------------------------------------------

Initialize Init method (Initialize daemon):

The main process in this method

1. Initialize class loader initclassloaders----------commonloader,catalinaloader,sharedloade will load catalina.base/conf/first Catalina.propertises configuration file

Then read the value of the Common.loader key

2. Set ClassLoader for the current thread

Thread.CurrentThread (). Setcontextclassloader (Catalinaloader); Catalinaloader is actually commonloader.

Pre-load class resources with static class Securityclassload

Securityclassload.securityclassload (Catalinaloader);

Securityclassload (ClassLoader loader, Boolean Requiresecuritymanager) {
。。。。。 Slightly..........
Loadcorepackage (loader); Loadcoyotepackage (loader); Loadloaderpackage (loader); Loadrealmpackage (loader); Loadservletspackage (loader); Loadsessionpackage (loader); Loadutilpackage (loader); Loadvalvespackage (loader); Loadwebresourcespackage (loader); Loadjavaxpackage (loader); Loadconnectorpackage (loader); Loadtomcatpackage (loader);
}

3. Initialization Org.apache.catalina.startup.Catalina uses reflection to invoke its Setparentclassloader settings sharedloader; (The reason and usefulness of setting up the Parentclassloader is not entirely clear, see source estimation will be used in the Server.xml loading section)

Specific source analysis: http://blog.csdn.net/u011545486/article/details/52002626

Tomcat Launcher (ii) ORG.APACHE.CATALINA.STARTUP.BOOTSTRAP analysis

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.