linghaiyan 发表于 2017-2-10 12:30:08

Tomcat源码解读--代码走读之(十八的2)StandardServer. startInternal(十九)

  

 
  1、fireLifecycleEvent(CONFIGURE_START_EVENT,null),其中CONFIGURE_START_EVENT = "configure_start"。其中6个listeners。
(1)、NamingContextListener
  1)、将NamingResources的namingResources 赋值为server.xml的GlobalNamingResources对象。
  2)、创建一个对象namingContext,是hashtable结构。
  3)、securityTokens.put(name,token),其中name=/,token= StandardServer.
  4)、ContextBindings.bindContext(container,namingContext, container),其中container为StandardServer.里面的步骤为contextNameBindings.put(name, context),其中name= StandardServer,context= NamingContext上一步构建的。
  5)、ContextAccessController.setWritable(getName(),container);里面的步骤为readOnlyContexts.remove(name); 其中name为/。
  6)、createNamingContext(),主要是检查Resourcelinks、Resources(server.xml的GlobalNamingResources的Resource,其中这里面对对象进行包装)、Resources Env、Environment entries、EJB references、WebServices references、Binding a User Transaction reference、Binding theresources directory context
  7)、ContextBindings.bindClassLoader (container, container,  this.getClass().getClassLoader()),其中container=StandardServer,this.getClass().getClassLoader()=sun.misc.Launcher$AppClassLoader@18d107f。意味着classloader与container做绑定,步骤如下。
  

 
  (2)、AprLifecycleListener,在此阶段没有动作。
  (3)、JasperListener,在此阶段没有动作。
  (4)、JreMemoryLeakPreventionListener,在此阶段没有动作。
  (5)、GlobalResourcesLifecycleListener,在此阶段没有动作。
  (6)、ThreadLocalLeakPreventionListener,在此阶段没有动作。
  2、setState(LifecycleState.STARTING),LifecycleState.STARTING=“start”流程还是6个listeners。(1)、NamingContextListener,在此阶段没有动作。
  (2)、AprLifecycleListener,在此阶段没有动作。
  (3)、JasperListener,在此阶段没有动作。
  (4)、JreMemoryLeakPreventionListener,在此阶段没有动作。
  (5)、GlobalResourcesLifecycleListener,创建mbean
  (6)、ThreadLocalLeakPreventionListener,在此阶段没有动作。
  3、globalNamingResources.start(),因为listeners为0,所以在此阶段没有动作。
  4、services.start(),后续介绍。
页: [1]
查看完整版本: Tomcat源码解读--代码走读之(十八的2)StandardServer. startInternal(十九)