All language subtitles for 024 Bean Lifecycle Methods - Overview_en

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese Download
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

Instructor: In this video,

we'll cover Bean Lifecycle Methods.

Here's a high-level view of the bean lifecycle.

When the Spring containers started,

beans are instantiated, dependencies are injected,

internal Spring processing occurs,

and then it can execute

your own custom initialization method.

And then at that point, your bean is ready to use.

And then once the container is shut down or stopped,

then they'll actually make a call

to your custom destroy method.

So what's the purpose

of these bean lifecycle methods or hooks?

Well, this is where you can add your own custom code

during bean initialization.

So calling custom business logic methods,

setting up handles to resources,

like databases, sockets, files.

You can also add custom code during bean destruction.

So again, calling some custom business logic,

or cleaning up handles to any resources

that you may have such as databases, sockets, files,

and so on.

Now, this is how we can set up the method configuration

for an init method.

We have our class here, in this example, CricketCoach,

and then we make use

of this annotation called PostConstruct.

And then we can provide a method here,

in this example, doMyStartupStuff.

You can give it any method name,

but the key here is that this is where you can add

your own custom initialization code

once the bean has been constructed.

And we can do a similar thing here for the destroy method.

So we make use of this annotation here, PreDestroy,

and we have a method, in this case,

public void doMyCleanupStuff.

Again, you can have any method name.

And this allows you to add your own custom logic here

for any cleanup work that you need to do.

Okay, so here's the basic development process.

So you go through and you define your methods

for init and destroy,

and then you add the annotations

for PostConstruct and PreDestroy.

All right, so the next video,

we'll go ahead and write the code

and we'll test out this functionality.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.