Hi All
I am new to Spring. Reading through a book and docs on net. I have a query with respect to bean scoping. As we know, the default scope in spring is singleton. As per my understanding, this means that only one instance of the bean will be created and shared whenever required. Required means either being wired into another bean or directly called through getBean method. Please correct if there is anything incorrect here.
Now please look at the following code.
All the beans (especially, "owner" bean) are default scoped as singleton. In a sample application however when I access owner via greetingService and useowner respectively, changes made by one are not reflected in the other. Aren't these two sharing a "single" owner instance?
If only one instance of owner is created then why this behavior. Is it one instance per container or something like one instance per "class type" per container. I am confused. I hope there isn't any basic
java polymorphism stuff here that I am not getting. Please help.