Hi
I am new to spring with practically no hands on experience with
EJB. I am not sure whether this question even makes sense.
While reading Manning Spring in Action I came across the singleton property of the bean - prototype | singleton. Googling a bit more on this
here, I read:
Beans are defined to be deployed in one of two modes: singleton or non-singleton. (The latter is also called a prototype, although the term is used loosely as it doesn't quite fit). When a bean is a singleton, only one shared instance of the bean will be managed and all requests for beans with an id or ids matching that bean definition will result in that one specific bean instance being returned.
The non-singleton, prototype mode of a bean deployment results in the creation of a new bean instance every time a request for that specific bean is done. This is ideal for situations where for example each user needs an independent user object or something similar.
Beans are deployed in singleton mode by default, unless you specify otherwise. Keep in mind that by changing the type to non-singleton (prototype), each request for a bean will result in a newly created bean and this might not be what you actually want. So only change the mode to prototype when absolutely necessary
Now the question: does bean instance corresponds to the bean object (speaking in
java terms)?
if yes, then in singleton deployment of bean, I will get the reference to the same object again and again and that makes it useless for things like student bean where I would like to create N number of students? So can you give some example where I would go for singleton beans.
Sorry for this long explanation of my problem, but was not sure how to put this all in words...
Thanks