I’ve been clicking on Spring for a while and I think I have a reasonable understanding of the concepts, however I got into the information in another of my threads that turned things upside down for me ...
"... although initialization lifecycle callback methods are called on all objects regardless of scope, in the case of prototypes, configuration lifecycle callbacks are not performed. Client code must clean up objects with a prototype and release expensive resources that are prototype bean (s). To get the Spring container to allocate resources stored in beans prototypes, try using a custom bean post processor that contains a link to beans that needs to be cleared. "
This made me think that I have real use cases when I would like to use a beans prototype where, for example, I need a “new” bean instance for each request. However, from what I understand from this snippet (from Spring 3 documents), Spring holds on to the beans reference that needs to be cleared (the link itself means that the bean will not be cleared automatically by the garbage collector). In addition, I take this because the resources stored in the prototype bean must be manually cleared.
Can anyone tell me if this is correct? If so, a typical pattern used to combat this? I would appreciate an answer that could explain the architectural reason Spring implements the beans prototype in this way.
Jlove source