• Post Reply Bookmark Topic Watch Topic
  • New Topic

Stateless Session Beans like SingleThreadModel?

 
Dushy Inguva
Ranch Hand
Posts: 264
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
javax.servlet.SingleThreadModel was deprecated a while ago. It used to provide
a guarantee that no two threads will execute concurrently in the servlet's service method. The servlet container can make this guarantee by synchronizing access to a single instance of the servlet, or by maintaining a pool of servlet instances and dispatching each new request to a free servlet. - from API
Lets assume that our servlet container does pooling.

But, as far as the stateless session bean goes, it too has the same characteristics right? How come session beans are scalable and Servlets implementing javax.servlet.SingleThreadModel are not?
Dushy
 
Roland Barcia
author
Ranch Hand
Posts: 181
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because stateless session beans are pooled. When a request comes in, the container will give the user a totally new instance from the bean pool. Servlets are (usually)not pooled, there is one instance and thus the web container will block other threads while the servlet is in use.
I think that the EJB spec should as a flag like <shared> that says that the EJB is thread safe and therefore everyone can share a single instance.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!