0

Confused with a “singleton bean” term in Spring 😳

Is it correct that a meaning of a “singleton object” pattern and a concept of a “singleton bean” in Spring are not the same? The original meaning of “singleton” doesn’t permit the possibility of multiple use of the same object. But in Spring you can use the same bean any time you need... Or am I overthinking again? đŸ€Ż

30th Jun 2018, 2:07 PM
Nina
Nina - avatar
3 Answers
0
Great glad to hear it's becoming clearer, good luck in your studies.
20th Jul 2018, 11:12 AM
Jose Ayala
Jose Ayala - avatar
0
I'm no Spring expert, but the concept of a singleton, at least the way I understand it is that there would only ever be one instance of the class but it could be used throughout the application. For example most applications have some sort of log where information is stored about user actions such as when they logged in what they did, when they logged out etc. The log class or in this case the bean would be a singleton because you wouldn't want multiple instances created you'd want all actions writing to the same log. So I'd imagine that the singleton bean you're referring to is an example of this, there would be only one instance of the bean but it is usable throughout the application, whenever it is needed. I think your interpretation of the original meaning of singleton may not be 100% accurate, I believe it means a single instance but does not indicate that the single instance can't be used multiple times.
2nd Jul 2018, 12:37 AM
Jose Ayala
Jose Ayala - avatar
0
okey, got it! 😊 thanx a lot! now I see it a little bit more clearly!
19th Jul 2018, 12:43 PM
Nina
Nina - avatar