Afrikaans
Akan
Albanian
Amharic
Arabic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
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.