File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Spring and the fly likes Core Container  dependency  Injection Behaviour? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Spring
Bookmark "Core Container  dependency  Injection Behaviour?" Watch "Core Container  dependency  Injection Behaviour?" New topic

Core Container dependency Injection Behaviour?

scott miles
Ranch Hand

Joined: Jun 16, 2011
Posts: 70
As core container inject the dependency with bean id defined in spring-config.xml. My question can configure the objects here which are
holding some state? I mean two request comes for the same object at same time , will container create the new instances for both of them
if the scope is prototype? Last question is does container maintain some pool for the created objects or they are good for garbage collection
as soon as they are finished?
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

If you set the scope to "prototype" everytime someone calls getBean() will get a new instance. However, typically, most beans are objects that do not hold state and having a single instance only is plenty to support many clients all at the same time. There would be no thread issues. Spring does not pool objects, there is no need for pools of Spring beans.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Core Container dependency Injection Behaviour?
It's not a secret anymore!