-
1. Re: EJB pooling best practices: obtain/release ejb reference
juha Jan 4, 2004 3:24 PM (in response to nic7834)The container is responsible for pooling instances, and will do so regardless of how the client stores the proxies to the bean (for instance, a stateless session instance is always returned back to the pool after a method invocation returns).
-
2. Re: EJB pooling best practices: obtain/release ejb reference
nic7834 Jan 6, 2004 10:34 PM (in response to nic7834)Ahh...ok. Thanks for clarifying.
Can you please explain the situation for entity beans then?
Hypothetically, If I obtain a collection of entity beans by invoking a finder method and pass this collection all the way up the business tier to the presentation tier then am i right in that the entity bean instances are held and not returned to their pool until the collection is eventually garbage collected.
I guess this is one reason why the relevant data should be copied into a new collection of data objects with the original collection being released as soon as possible (so as to return to the pool).
Nic -
3. Re: EJB pooling best practices: obtain/release ejb reference
juha Jan 7, 2004 2:30 AM (in response to nic7834)Again, what you are returning is a collection of proxies that are disconnected from the actual entity instances on the server. The server may do whatever it sees fit with the instances (cache them, or not) and what you do with your entity proxies has no relation to it.
-
4. Re: EJB pooling best practices: obtain/release ejb reference
nic7834 Jan 12, 2004 3:07 PM (in response to nic7834)If that's the case, then can you explain if there is a need to call the bean interface remove() method at all from the client side. What will this achieve? Nothing for a stateless session bean and deleting the associated table row for an entity bean?
What should I be doing on the client side once I'm done with the bean. Call the remove() method, then set the bean variable to null? From what I understand that you are saying is I don't have to do anything at all as far as telling JBoss to release resources (i.e bean instances) because JBoss is not holding anything.
I am also using only local interfaces, so does the same apply?
Thanks again! -
5. Re: EJB pooling best practices: obtain/release ejb reference
darranl Jan 13, 2004 4:29 AM (in response to nic7834)If that's the case, then can you explain if there is a need to call the bean interface remove() method at all from the client side. What will this achieve? Nothing for a stateless session bean and deleting the associated table row for an entity bean?
Calling remove gives the application server an opportunity to optimise the number of beans held in pools as it will allow it to keep track of the number of clients that could still invoke a method on the bean.
So basically to make it easier to move your application to other application servers you should call remove when you have finished with a session bean.