Jan 11th, 2011, 09:38 AM
Question about prototype scope bean
If I inject a singleton datasource to a prototype scope bean, do I need to add a post-processor for the prototype bean to destroy/release the datasource?
If I don't, will the datasource be hold by the prototype bean forever (till the application is shut down)?
Thanks in advance.
Jan 12th, 2011, 12:31 PM
If the prototype bean lives for the life of the application then the datasource be referenced by it. However, if the prototype bean is tied to a thread then it will be destroyed when the thread ends. Usually a datasource bean is thread-safe. This means that there is nothing wrong with multiple prototype beans having a reference to the datasource bean. I hope this helps.
Jan 12th, 2011, 02:44 PM