标题和上一篇很像,所以特别强调一下,这个是Tomcat对象的。
从TomcatEmbeddedServletContainer的this.tomcat.start()开始,主要是利用LifecycleBase对这一套容器(engine,host,context及wrapper)进行启动并发布诸如configure_start、before_init、after_start的lifecycleEvent事件给相应的监听器(如果有的话)。进入start,因为此时状态是LifecycleState.NEW,所以会执行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); } }