• Post Reply Bookmark Topic Watch Topic
  • New Topic

Why do we need to pool Stateless Beans  RSS feed

 
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Stateless beans in Java do not keep their state between two calls from the client. So in a nutshell we might consider them as objects with business methods. Each method takes parameters and return results. When the method is invoked some local variables are being created in execution stack. When the method returns the locals are removed from the stack and if some temporary objects were allocated they are garbage collected anyway.

From my perspective that doesn�t differ from calling method of the same single instance by separate threads. So why cannot a container use one instance of a bean instead of pooling a number of them?

Thanks,
Srikanth.
 
Ranch Hand
Posts: 354
Eclipse IDE Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

From my perspective that doesn�t differ from calling method of the same single instance by separate threads.


But that won't gurantee thread-safety. Pooling helps wrt
1. Reusing beans
2. Ability to shrink/expand the pool size to make
the app scalable.
 
Sheriff
Posts: 10447
227
IntelliJ IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Discussed here
 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does EJB3 Spec mandates stateless session beans to be thread safe. That's the only reason i could think for having stateless session bean pooling.

Am i right?
 
I promise I will be the best, most loyal friend ever! All for this tiny ad:
The WEB SERVICES and JAX-RS Course
https://coderanch.com/t/690789/WEB-SERVICES-JAX-RS
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!