Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stateless session beans pool

 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to everybody,
I've started studying EJB 3.0 and I have a doubt about stateless SessionBean pool: why should I have a lot of SessionBean instances even if they are stateless? Could not proxies invoke an unique SessionBean?

Thanks in advances
 
Camilo Morales
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mirko Bonasorte:
Hi to everybody,
I've started studying EJB 3.0 and I have a doubt about stateless SessionBean pool: why should I have a lot of SessionBean instances even if they are stateless? Could not proxies invoke an unique SessionBean?

Thanks in advances


The reason is that the beans EJBContext carry information about the client that is requesting the service (method), and because each Session instance have its own EJBContext, the container need one session instance per client request.

This paragraph of "Enterprise Javabeans 3.0, O'Reilly, Chapter 3.1. Resource Management", might be useful:

When a bean instance is servicing a request, the EJBContext takes on new meaning. The EJBContext provides information about the client that is using the bean. It also provides the instance with access to its own EJB stub proxy, which is useful when the bean needs to pass references to itself or to other enterprise beans. So the EJBContext is not a static class; it is an interface to the container.


Hope this helps,
 
Mirko Bonasorte
Ranch Hand
Posts: 244
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Understood!
Thanks for your answer!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic