Announcement Announcement Module
No announcement yet.
Question about prototype scope bean Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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.

  • #2
    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.


    • #3
      Thanks a lot.