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