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: Let's take care of our normal Housekeeping,
stopping all apps and closing all windows.
And in my file system here,
I'll just do a copy paste on this project.
O six lazy initialization
and I'll rename it as O seven bean scopes.
And then I'll go ahead and open this up in IntelliJ.
I'll do a rebuild on the project here
and I'll remove the lazy initialization
and I'll also remove the global configuration for lazy-init.
I'll open up the application properties here
and just remove that configuration.
And then I'll do a similar thing here on the track coach,
remove that lazy annotation.
And again, just cleaning up,
just so I have some basic code to start with.
All right, so let's go ahead
and move into our demo controller here
and let's add a new field.
I'll create this coach, another coach
and then I'll update my constructor to inject another coach.
Here I have qualifier and I have cricket coach
and then I have coach the another coach.
And then inside of this constructor here,
I make the appropriate assignments.
So I'll have another coach equals the another coach.
All right so that's our new constructor,
that has been updated here.
And again, a couple things to point out here.
The default scope is singleton,
so all dependency injections for the bean,
will reference the same bean.
Let's also add some code here at the bottom,
to check the bean scopes.
So I'll just stretch out here at the bottom,
give myself some room to work with.
I'll add this new get mapping slash check
and I'll return comparing beans.
And in parens, I'll give my coach,
equals equals another coach,
just to see if they point to the same thing.
Okay, so again, we're checking to see,
if this is the same beans.
So true or false, depending on the bean scope.
If it's singleton, it should return true,
prototype return false.
All righty, so we'll swing out here
and we'll go ahead and run this application.
Okay, so our application is up and running.
Open up our browser.
Just go to this local host 8080 slash check.
All righty, great.
So we're checking to see if this is the same bean.
By default we have singleton scope,
hence true, this kind of works out as desired.
Now let's swing back into our application code here.
And now what I wanna do is move over to the cricket coach
and change the bean scope to prototype.
I make use of the scope annotation
and then I choose scope of prototype.
Now remember with this prototype scope,
a new object instance is created for each injection.
And now swinging back over to the controller,
just as a refresh here with prototype scope,
new object instance for each injection.
And so out there we'll have two different objects,
that are injected and so they won't point to the same.
So this should return false for us.
So now browser, move over here and do a reload
and excellent false.
So again, we're checking to see if it's the same bean,
since we have prototype scope, hence false,
because we have two separate objects that were created
and it's not pointing to the exact same object.
All right, so this kind of works out as desired.
A good example here of using scopes,
the default singleton scope, and also the prototype scope.
So I'd like to say good job my friend.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.