Tomcat loading web. xml

Source: Internet
Author: User

These days to see the source of Tomcat, a lot of questions, such as one of the "Tomcat How to load Web. xml", the following is the process of tracking, where the event listener has an observer pattern, better. Recorded for reference

1>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>tomcat Load web.xml>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>>2    3    4    5Tomcat loads the user's servlet into the context in Web. XML and instantiates the servlet to/web-inf/classes/in6 The process is generally as follows7    8 The action to load the Web. XML is triggered only when the message received by the event receiver is configure_start_event.9    Ten            /** One * The lifecycleevent type for the "Configure_start" event. Used by those A * Components of Use a separate component to perform configuration and - * need to signal when configuration should is performed-usually after -              * {@link#BEFORE_START_EVENT} and before {@link#START_EVENT}. the              */ -              Public Static FinalString configure_start_event = "Configure_start"; -      - so who's going to register the message in the listener? As below, look for it from the startup process: +     -    + Org.apache.catalina.startup.Bootstrap.start () A-Org.apache.catalina.startup.Catalina.start () at----"Load () -------" - getserver (). Init (); -server=== "Org.apache.catalina.core.StandardServer" ------"standardserver.initinternal () - standardserver.startinternal () in---" -                     voidjava.org.apache.catalina.util.LifecycleBase.fireLifecycleEvent (String type, Object data) to                               +Firelifecycleevent (Configure_start_event,NULL); ----" theLifecyclesupport firelifecycleevent (Configure_start_event,NULL); *                                  $ broadcast by Lifecyclesupport to all the receivers,Panax Notoginseng the receiver determines whether it needs to handle "Observer mode here" as needed -   the                                           +                          Aand publicclassContextconfigImplementsLifecyclelistener the is the so-called recipient + in its overridden lifecycleevent (Lifecycleevent event) method -                               $                               if(Event.gettype (). Equals (Lifecycle.configure_start_event)) { $                                          - Configurestart (); This method is the specific method for loading -       the      -             protected synchronized voidConfigurestart ()Wuyi-----------------"Webconfig () the : :::: -        Wu webconfig () in -                            { AboutString resource = $"/web-inf/classes/" +binding.getname (); -                                                     Try { -URL url =Scontext.getresource (Resource); - processannotationsurl (URL, webxml, A Webxml.ismetadatacomplete ()); +}Catch(malformedurlexception e) { the Log.error (sm.getstring ( -"Contextconfig.webinfclassesurl", $ Resource), e); the                                                     } the                                the                            } the     ----------------" in     voidJava.org.apache.catalina.startup.ContextConfig.processAnnotationsUrl (URL url, webxml fragment,Booleanhandlestypesonly) the----------" the                  voidJava.org.apache.catalina.startup.ContextConfig.processAnnotationsJndi (URL url, webxml fragment,Booleanhandlestypesonly) About------------" the                              voidJava.org.apache.catalina.startup.ContextConfig.processAnnotationsStream (InputStream is, webxml fragment,BooleanHANDLESTYPESONLY)throwsclassformatexception, IOException the--------------" the                                          voidJava.org.apache.catalina.startup.ContextConfig.processAnnotationWebServlet (String className, Annotationentry AE, webxml fragment) +  ----------" the Fragment.addservlet (servletdef);Bayi fragment.addservletmapping (Urlpattern, servletname); the   the   -------->Webxml.configurecontext (context); -   the                   Public voidConfigurecontext (Context context) { theWrapper Wrapper =Context.createwrapper (); the Context.addchild (wrapper); the context.addservletmapping (Entry.getkey (), Entry.getvalue ()); -      the>>>>>>>>>>>>>>>>>>>>>>>>>>> >>>>>>>>>>tomcat Load web.xml>>>>>>>>>>>>> >>>>>>>>>>>>>>>>>>>>>>>> the    the     

Tomcat loading web. xml

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.