LifeCycelBase作为众多组件的父类,其init()方法,第一次调用用是在StandardServer的start()方法中,其方法内容如下:
setStateInternal(LifecycleState.INITIALIZING, null, false); initInternal(); setStateInternal(LifecycleState.INITIALIZED, null, false);第一个方法是把组件的状态设置为了INITIALIZING。
第二个方法是是进入了StandardServer的initInternal()方法。
其initInternal方法如下,我们选择比较重要的部分显示:
super.initInternal(); // Register global String cache // Note although the cache is global, if there are multiple Servers // present in the JVM (may happen when embedding) then the same cache // will be registered under multiple names onameStringCache = register(new StringCache(), "type=StringCache"); // Register the MBeanFactory MBeanFactory factory = new MBeanFactory(); factory.setContainer(this); onameMBeanFactory = register(factory, "type=MBeanFactory"); // Register the naming resources globalNamingResources.init(); // Initialize our defined Services for (int i = 0; i < services.length; i++) { services[i].init(); }第一行的super.initinternal()方法,是调用了父类LifeCycleMBeanBase的initInternal()方法,注册了MBean。后面主要是执行了与MBean相关的一些操作,重要的是最后一段,调用了services的init()方法,然后到了StandardService的initInternal方法。
可以看到,后面调用了StandardEngine的init()方法,并调用了其initInternal方法,
StandardService.InitInternal方法调用了StandardEngine的initInternal方法后,又调用了Connector的initInternal方法,
Connector的initInternal方法意义在此