tomcat 容器生命周期lifecycle
生活随笔
收集整理的這篇文章主要介紹了
tomcat 容器生命周期lifecycle
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
1.復習java的事件機制
java事件機制包括三個部分:事件、事件監聽器、事件源。
事件:一般繼承自java.util.EventObject類,封裝了事件源對象及跟事件相關的信息。
事件監聽器:實現java.util.EventListener接口,注冊在事件源上,當事件源的屬性或狀態改變時,取得相應的監聽器調用其內部的回調方法。
事件源:事件發生的地方,由于事件源的某項屬性或狀態發生了改變(比如BUTTON被單擊、TEXTBOX的值發生改變等等)導致某項事件發生。
2. tomcat的lifecycle
?事件定義
public final class LifecycleEvent extends EventObject { ? ??? private static final long serialVersionUID = 1L; ? ? ??? // ----------------------------------------------------------- Constructors ? ??? /** ???? * Construct a new LifecycleEvent with the specified parameters. ???? * ???? * @param lifecycle Component on which this event occurred ???? * @param type Event type (required) ???? * @param data Event data (if any) ???? */ ??? public LifecycleEvent(Lifecycle lifecycle, String type, Object data) { ? ??????? super(lifecycle); ??????? this.type = type; ??????? this.data = data; ??? }}
事件監聽器
/** * Interface defining a listener for significant events (including "component * start" and "component stop" generated by a component that implements the * Lifecycle interface. The listener will be fired after the associated state * change has taken place. * * @author Craig R. McClanahan * @version $Id: LifecycleListener.java 1200160 2011-11-10 05:35:13Z kkolinko $ */ ? public interface LifecycleListener { ? ? ??? /** ???? * Acknowledge the occurrence of the specified event. ???? * ???? * @param event LifecycleEvent that has occurred ???? */ ??? public void lifecycleEvent(LifecycleEvent event); ? ? } *??????????? start() *? ----------------------------- *? |?????????????????????????? | *? | init()??????????????????? | * NEW ->-- INITIALIZING??????? | * | |?????????? |????????????? |???? ------------------<----------------------- * | |?????????? |auto????????? |???? |??????????????????????????????????????? | * | |????????? \|/??? start() \|/?? \|/???? auto????????? auto????? ???stop() | * | |????? INITIALIZED -->-- STARTING_PREP -->- STARTING -->- STARTED -->---? | * | |???????? |????????????????????????????????????????????????? |???????? |? | * | |???????? |????????????????????????????????????????????????? |???????? |? | * | |???????? |????????????????????????????????????????????????? |???????? |? | * | |destroy()|????????????????????????????????????????????????? |???????? |? | * | -->-----<--?????? auto??????????????????? auto?????????????? |???????? |? | * |???? |??? ???---------<----- MUST_STOP ---------------------<--???????? |? | * |???? |?????? |????????????????????????????????????????????????????????? |? | * |??? \|/????? ---------------------------<--------------------------------? ^ * |???? |?????? |???????? ????????????????????????????????????????????????????| * |???? |????? \|/??????????? auto???????????????? auto????????????? start()? | * |???? |? STOPPING_PREP ------>----- STOPPING ------>----- STOPPED ---->------ * |???? |????????????????????????????? ??^????????????????? |? |? ^ * |???? |?????????????? stop()?????????? |????????????????? |? |? | * |???? |?????? --------------------------????????????????? |? |? | * |???? |?????? |????????????????????????????????? auto???? |? |? | * |???? |?????? |? ????????????????MUST_DESTROY------<-------? |? | * |???? |?????? |??????????????????? |???????????????????????? |? | * |???? |?????? |??????????????????? |auto???????????????????? |? | * |???? |?????? |??? destroy()????? \|/????????????? destroy() |? | * |???? |??? FAILED ---->------ DESTROYING ---<-----------------? | * |???? |??????????????????????? ^???? |????????????????????????? | * |???? |???? destroy()????????? |???? |auto????????????????????? | * |???? -------->-----------------??? \|/?????? ??????????????????| * |???????????????????????????????? DESTROYED???????????????????? | * |?????????????????????????????????????????????????????????????? | * |??????????????????????????? stop()???????????????????????????? | * --->------------------------------>------------------------------public interface Lifecycle
?
3. lifecycle在tomcat中的使用。
public interface Server extends Lifecycle ? public interface Service extends Lifecycle ? public interface Container extends Lifecycle轉載于:https://www.cnblogs.com/davidwang456/p/3253523.html
總結
以上是生活随笔為你收集整理的tomcat 容器生命周期lifecycle的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: tomcat server容器解读
- 下一篇: 转载--tomcat整合apr