ejb@glassfish.java.net

[Fwd: _at_EJB to inject a EJB 3.0 style stateful session bean in a Servlet class]

From: Sanjeeb Kumar Sahoo <Sanjeeb.Sahoo_at_Sun.COM>
Date: Sun, 26 Feb 2006 23:03:59 +0530

Hi,

Looks like I never got an answer to this question I had in the forwarded
email. Now a user has similar doubt as seen here:

http://forums.java.net/jive/thread.jspa?threadID=13439

I will be glad if someone can clarify the scenario.

Thanks,
Sahoo

attached mail follows:



Hi,

I am not able to understand how one can inject a stateful session bean
into a servlet using @EJB.
e.g. this is what I am doing now:

public class MyServlet extends HttpServlet {
   @EJB private ShoppingCart cart;
   public void service()... {
      cart.doSomething();
   }
}

 Since injected stateful session bean (e.g.) cart will be shared by
multiple threads executing servlet's service() and a stateful session
bean instance only serves one request at a time, request processing can
not happen concurrently, right? So how can I inject a stateful session
bean and yet expect my request processing to happen concurrently?

Thanks,
Sahoo