home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-tomcat-addon-1.4.9-installer.exe / serverStartup.txt < prev    next >
Encoding:
Text File  |  2004-08-28  |  7.3 KB  |  136 lines

  1. Tomcat 5 Startup Sequence
  2.  
  3.  
  4.  
  5. Sequence 1. Start from Command Line
  6.  
  7. Class: org.apache.catalina.startup.Bootstrap
  8.  
  9. What it does:
  10.  
  11.     a) Set up classloaders 
  12.  
  13.         commonLoader (common)-> System Loader
  14.  
  15.         sharedLoader (shared)-> commonLoader -> System Loader
  16.  
  17.         catalinaLoader(server) -> commonLoader -> System Loader
  18.  
  19.     b) Load startup class (reflection)
  20.  
  21.         org.apache.catalina.startup.Catalina
  22.  
  23.         setParentClassloader -> sharedLoader
  24.  
  25.         Thread.contextClassloader -> catalinaLoader
  26.  
  27.     c) Bootstrap.daemon.init() complete
  28.  
  29.     
  30.  
  31. Sequence 2. Process command line argument (start, startd, stop, stopd)
  32.  
  33. Class: org.apache.catalina.startup.Bootstrap (assume command->start)
  34.  
  35. What it does: 
  36.  
  37.     a) Catalina.setAwait(true);
  38.  
  39.     b) Catalina.load()
  40.  
  41.         b1) initDirs() -> set properties like 
  42.  
  43.                           catalina.home
  44.  
  45.                           catalina.base == catalina.home (most cases)
  46.  
  47.         b2) initNaming
  48.  
  49.             setProperty(javax.naming.Context.INITIAL_CONTEXT_FACTORY,
  50.  
  51.                     org.apache.naming.java.javaURLContextFactory ->default)
  52.  
  53.         b3) createStartDigester() 
  54.  
  55.             Configures a digester for the main server.xml elements like
  56.  
  57.             org.apache.catalina.core.StandardServer (can change of course :)
  58.  
  59.             org.apache.catalina.deploy.NamingResources
  60.  
  61.                 Stores naming resources in the J2EE JNDI tree
  62.  
  63.             org.apache.catalina.LifecycleListener
  64.  
  65.                 implements events for start/stop of major components
  66.  
  67.             org.apache.catalina.core.StandardService
  68.  
  69.                 The single entry for a set of connectors,
  70.  
  71.                 so that a container can listen to multiple connectors
  72.  
  73.                 ie, single entry
  74.  
  75.             org.apache.coyote.tomcat5.CoyoteConnector
  76.  
  77.                 Connectors to listen for incoming requests only
  78.  
  79.             It also adds the following rulesets to the digester
  80.  
  81.                 NamingRuleSet
  82.  
  83.                 EngineRuleSet
  84.  
  85.                 HostRuleSet
  86.  
  87.                 ContextRuleSet
  88.  
  89.         b4) Load the server.xml and parse it using the digester
  90.  
  91.             Parsing the server.xml using the digester is an automatic
  92.  
  93.             XML-object mapping tool, that will create the objects defined in server.xml
  94.  
  95.             Startup of the actual container has not started yet.
  96.  
  97.         b5) Assigns System.out and System.err to the SystemLogHandler class
  98.  
  99.         b6) Calls intialize on all components, this makes each object register itself with the 
  100.  
  101.             JMX agent.
  102.  
  103.             During the process call the Connectors also initialize the adapters.
  104.  
  105.             The adapters are the components that do the request pre-processing.
  106.  
  107.             Typical adapters are HTTP1.1 (default if no protocol is specified,
  108.  
  109.             org.apache.coyote.http11.Http11Protocol)
  110.  
  111.             AJP1.3 for mod_jk etc.
  112.  
  113.  
  114.  
  115.     c) Catalina.start()
  116.  
  117.         c1) Starts the NamingContext and binds all JNDI references into it
  118.  
  119.         c2) Starts the services under <Server> which are:
  120.  
  121.             StandardService -> starts Engine (ContainerBase ->Logger,Loader,Realm,Cluster etc)
  122.  
  123.         c3) StandardHost (started by the service)
  124.  
  125.                 Configures a ErrorReportValvem to do proper HTML output for different HTTP 
  126.  
  127.                 errors codes
  128.  
  129.                 Starts the Valves in the pipeline (at least the ErrorReportValve)
  130.  
  131.                 Configures the StandardHostValve, 
  132.  
  133.                     this valves ties the Webapp Class loader to the thread context
  134.  
  135.                     it also finds the session for the request
  136.  
  137.                     and invokes the context pipeline
  138.  
  139.                 Starts the HostConfig component
  140.  
  141.                     This component deploys all the webapps
  142.  
  143.                         (webapps & conf/Catalina/localhost/*.xml)
  144.  
  145.                     Webapps are installed using the deployer (StandardHostDeployer)
  146.  
  147.                     The deployer will create a Digester for your context, this digester
  148.  
  149.                     will then invoke ContextConfig.start()
  150.  
  151.                         The ContextConfig.start() will process the default web.xml (conf/web.xml)
  152.  
  153.                         and then process the applications web.xml (WEB-INF/web.xml)
  154.  
  155.                         
  156.  
  157.         c4) During the lifetime of the container (StandardEngine) there is a background thread that 
  158.  
  159.             keeps checking if the context has changed. If a context changes (timestamp of war file, 
  160.  
  161.             context xml file, web.xml) then a reload is issued (stop/remove/deploy/start)
  162.  
  163.             
  164.  
  165.     d) Tomcat receives a request on an HTTP port
  166.  
  167.         d1) The request is received by a separate thread which is waiting in the PoolTcpEndPoint 
  168.  
  169.              class. It is waiting for a request in a regular ServerSocket.accept() method.
  170.  
  171.              When a request is received, this thread wakes up.
  172.  
  173.         d2) The PoolTcpEndPoint assigns the a TcpConnection to handle the request. 
  174.  
  175.             It also supplies a JMX object name to the catalina container (not used I believe)
  176.  
  177.         d3) The processor to handle the request in this case is Coyote Http11Processor, 
  178.  
  179.             and the process method is invoked.
  180.  
  181.             This same processor is also continuing to check the input stream of the socket
  182.  
  183.             until the keep alive point is reached or the connection is disconnected.
  184.  
  185.         d4) The HTTP request is parsed using an internal buffer class (Coyote Http11 Internal Buffer)
  186.  
  187.             The buffer class parses the request line, the headers, etc and store the result in a 
  188.  
  189.             Coyote request (not an HTTP request) This request contains all the HTTP info, such
  190.  
  191.             as servername, port, scheme, etc.
  192.  
  193.         d5) The processor contains a reference to an Adapter, in this case it is the 
  194.  
  195.             Coyote Tomcat 5 Adapter. Once the request has been parsed, the Http11 processor
  196.  
  197.             invokes service() on the adapter. In the service method, the Request contains a 
  198.  
  199.             CoyoteRequest and CoyoteRespons (null for the first time)
  200.  
  201.             The CoyoteRequest(Response) implements HttpRequest(Response) and HttpServletRequest(Response)
  202.  
  203.             The adapter parses and associates everything with the request, cookies, the context through a 
  204.  
  205.             Mapper, etc
  206.  
  207.         d6) When the parsing is finished, the CoyoteAdapter invokes its container (StandardEngine)
  208.  
  209.             and invokes the invoke(request,response) method.
  210.  
  211.             This initiates the HTTP request into the Catalina container starting at the engine level
  212.  
  213.         d7) The StandardEngine.invoke() simply invokes the container pipeline.invoke()
  214.  
  215.         d8) By default the engine only has one valve the StandardEngineValve, this valve simply
  216.  
  217.             invokes the invoke() method on the Host pipeline (StandardHost.getPipeLine())
  218.  
  219.         d9) the StandardHost has two valves by default, the StandardHostValve and the ErrorReportValve
  220.  
  221.         d10) The standard host valve associates the correct class loader with the current thread
  222.  
  223.              It also retrives the Manager and the session associated with the request (if there is one)
  224.  
  225.              If there is a session access() is called to keep the session alive
  226.  
  227.         d11) After that the StandardHostValve invokes the pipeline on the context associated
  228.  
  229.              with the request.
  230.  
  231.         d12) The first valve that gets invoked by the Context pipeline is the FormAuthenticator
  232.  
  233.              valve. Then the StandardContextValve gets invoke.
  234.  
  235.              The StandardContextValve invokes any context listeners associated with the context.
  236.  
  237.              Next it invokes the pipeline on the Wrapper component (StandardWrapperValve)
  238.  
  239.         d13) During the invokation of the StandardWrapperValve, the JSP wrapper (Jasper) gets invoked
  240.  
  241.              This results in the actual compilation of the JSP.
  242.  
  243.              And then invokes the actual servlet.
  244.  
  245.     e) Invokation of the servlet class
  246.  
  247.              
  248.  
  249.              
  250.  
  251.              
  252.  
  253.         
  254.  
  255.             
  256.  
  257.             
  258.  
  259.             
  260.  
  261.         
  262.  
  263.             
  264.  
  265.             
  266.  
  267.         
  268.  
  269.         
  270.  
  271.