Cov txheej txheem:

Bean lifecycle yog dab tsi?
Bean lifecycle yog dab tsi?

Video: Bean lifecycle yog dab tsi?

Video: Bean lifecycle yog dab tsi?
Video: Plob hau hle ntau ntau yog vim li cas?/Cause of alopecia(Hair loss)/ສາເຫດຂອງຜົມຫຼົ່ນ 2024, Tej zaum
Anonim

1.1 Caij nplooj ntoos hlav Bean Lifecycle

Caij nplooj ntoos hlav taum yog lub luag hauj lwm rau kev tswj cov lub neej voj voog ntawm taum tsim los ntawm lub thawv caij nplooj ntoos hlav. Cov taum lifecycle muaj cov txheej txheem tom qab pib pib thiab ua ntej kev puas tsuaj hu rov qab.

Raws li txoj cai, lub neej voj voog ntawm lub caij nplooj ntoos hlav taum yog dab tsi?

Caij nplooj ntoos hlav (Kaw) Bean Lifecycle . Cov Caij nplooj ntoos hlav IoC (Inversion of Control) thawv tswj Caij nplooj ntoos hlav taum . A Caij nplooj ntoos hlav taum ” tsuas yog ib Caij nplooj ntoos hlav - tswj instantiation ntawm Java chav kawm. Cov Caij nplooj ntoos hlav IoC lub thawv yog lub luag haujlwm rau instantiating, pib, thiab xaim taum . Lub thawv kuj tswj cov lub neej voj voog ntawm taum.

Ib yam li ntawd, yuav ua li cas tswj taum lub neej voj voog nyob rau lub caij nplooj ntoos hlav? Lub caij nplooj ntoo hlav muab cov hauv qab no 4 txoj hauv kev los tswj cov xwm txheej hauv lub neej ntawm cov taum:

  1. InitializingBean thiab DisposableBean callback interfaces.
  2. * Paub interfaces rau tus cwj pwm tshwj xeeb.
  3. Kev cai init() thiab rhuav tshem() txoj hauv kev taum cov ntaub ntawv.
  4. @PostConstruct thiab @PreDestroy annotations.

Yog li ntawd, lub noob taum lub neej voj voog nyob rau hauv lub caij nplooj ntoos hlav taum Hoobkas ntim yog dab tsi?

Caij nplooj ntoos hlav - Bean Life Cycle . Cov lub neej voj voog ntawm a Caij nplooj ntoos hlav taum yooj yim to taub. Thaum a taum yog instantiated, nws yuav tsum tau ua ib co pib kom nws mus rau hauv lub xeev usable. Ib yam li ntawd, thaum lub taum tsis tas yuav tsum tau thiab raug tshem tawm ntawm lub thawv , tej zaum yuav tsum tau ua kom huv.

Taum pib li cas thaum lub caij nplooj ntoos hlav?

Spring Bean Life Cycle Cov ntsiab lus tseem ceeb:

  1. Los ntawm lub console tso zis nws yog tseeb hais tias lub caij nplooj ntoos hlav ntsiab lus yog thawj zaug uas tsis muaj-args constructor los pib lub taum yam khoom thiab ces hu rau lub post-init txoj kev.
  2. Qhov kev txiav txim ntawm taum pib yog tib yam li nws tau hais nyob rau hauv cov ntaub ntawv taum caij nplooj ntoos hlav configuration.

Pom zoo: