Tomcat6 source code learning 1.0.0 _ Catalina class

Source: Internet
Author: User
Tags xml parser

1 Catalina extends embedded

2 public class embedded extends standardservice implements Lifecycle
2.1 Public class embedded extends standardservice implements Lifecycle
2.1.1 public class standardservice implements lifecycle, service, mbeanregistration
2.1.1.1 = 3
2.1.1.2 public interface service
2.1.1.3 mbeanregistration
3 Public interface Lifecycle

3.1 lifecycle includes the following content:
Public static final string init_event = "init ";
Public static final string before_start_event = "before_start ";
Public static final string after_start_event = "after_start ";
Public static final String STOP_EVENT = "stop ";
Public static final String BEFORE_STOP_EVENT = "before_stop ";
Public static final String AFTER_STOP_EVENT = "after_stop ";
Public static final String DESTROY_EVENT = "destroy ";
Public static final String PERIODIC_EVENT = "periodic ";

Public void addLifecycleListener (LifecycleListener listener );
Public LifecycleListener [] findLifecycleListeners ();
Public void removeLifecycleListener (LifecycleListener listener );
Public void start () throws LifecycleException;
Public void stop () throws LifecycleException;

// Lifecycle describes the life cycle of the program running

4 manual debugging
Public static void main (String args []) {
String argsNew [] = {"start"}; // manually add this parameter
(New Catalina (). process (argsNew );
}

4.1 initialize Catalina // goto
4.1.1 public Embedded (){
This (null); // go 1.2
}

4.1.2 public Embedded (Realm realm ){

Super ();
SetRealm (realm );
SetSecurityProtection (); // go 1.3

}
4.1.3 protected void setSecurityProtection (){
SecurityConfig securityConfig = SecurityConfig. newInstance (); // read the resource file catalina. properties
SecurityConfig. setPackageDefinition ();
SecurityConfig. setPackageAccess ();
}
// Initialization is complete
4.2 process (args) Execution

Digester digester = createStartDigester (); // the required system attribute. The content is an element in server. xml.
// This is a great object. For details, refer to section "simplify XML document processing with Digester ".
Digester for server. xml created // we can see that tomcat first sets the result of server. xml in digester, and then parses

Follow these steps to resolve
InputSource. setByteStream (inputStream); // read the file
Digester. push (this); // press stack 4.2.1
Digester. parse (inputSource); // 4.2.2 parse server. xml
InputStream. close ();

4.2.2.1
Public Object parse (InputSource input) throws IOException, SAXException {
Configure (); // parser 4.2.2.1.1
GetXMLReader (). parse (input );
Return (root );

}
4.2.2.1.1
// The following two items seem to be the tomcat-specific XML parser.
Log = LogFactory. getLog ("org. apache. commons. digester. Digester ");
SaxLog = LogFactory. getLog ("org. apache. commons. digester. Digester. sax ");
// The fact is that this parser com.sun.org. apache. xerces. internal. jaxp. SAXParserImpl

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.