標(biāo)題和上一篇很像,所以特別強(qiáng)調(diào)一下,這個(gè)是Tomcat對(duì)象的。
從TomcatEmbeddedServletContainer的this.tomcat.start()開(kāi)始,主要是利用LifecycleBase對(duì)這一套容器(engine,host,context及wrapper)進(jìn)行啟動(dòng)并發(fā)布諸如configure_start、before_init、after_start的lifecycleEvent事件給相應(yīng)的監(jiān)聽(tīng)器(如果有的話)。進(jìn)入start,因?yàn)榇藭r(shí)狀態(tài)是LifecycleState.NEW,所以會(huì)執(zhí)行init方法:
public final synchronized void init() throws LifecycleException { if(!this.state.equals(LifecycleState.NEW)) { this.invalidTransition("before_init"); } try { this.setStateInternal(LifecycleState.INITIALIZING, (Object)null, false); this.initInternal(); this.setStateInternal(LifecycleState.INITIALIZED, (Object)null, false); } catch (Throwable var2) { ExceptionUtils.handleThrowable(var2); this.setStateInternal(LifecycleState.FAILED, (Object)null, false); throw new LifecycleException(sm.getString("lifecycleBase.initFail", new Object[]{this.toString()}), var2); } }