Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

A bean cannot use both container and bean managed.

 
Himai Minh
Ranch Hand
Posts: 1296
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
On p.14 of Frit's notes

A singleton bean cannot use both container managed and bean managed concurrency.


I think any bean (singleton, stateless and stateful) cannot use both container managed and bean managed concurrency.
Reason:
A stateless or stateful bean are not shared by more than one client at a time, so I think they don't even need container/bean managed concurrency control at all. It won't make sense to use either or both managed concurrency control for a stateless or stateful bean.

Any comments?
 
Mike Degteariov
Ranch Hand
Posts: 145
8
Java Mac MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
javax.ejb.ConcurrencyManagement annotation only works for singleton session beans.

It has no effect to other kinds of EJBs.

Here's where it is stated:
http://docs.oracle.com/javaee/6/api/javax/ejb/ConcurrencyManagement.html

It is said explicitly that "This annotation may be applied to stateful session beans, but doing so has no impact on the semantics of concurrency management for such beans."
 
Himai Minh
Ranch Hand
Posts: 1296
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your concurrency management documentation.
In EJB in Action, as I remember, it does not mention any concurrency for stateless bean. Does stateless bean need concurrency management?
 
Mike Degteariov
Ranch Hand
Posts: 145
8
Java Mac MySQL Database Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stateless session bean only serve one client at a time.
This means that for the duration of the call this particular instance of stateless EJB will not be used to fulfil other requests.
Once the call to stateless EJB is completed, the bean returns to the pool and becames available for future calls.

If two different clients send two different requests to the same stateless session bean SIMULTANEOUSLY, most likely (an exception explained in next statement) they will be served by two different instances of this EJB taken (by the container) from the pool of available instances.
Note If the size of the pool is smaller that the number of simultaneous requests, there might be no new instance of stateless EJB available to fulfil the request, and so if it happens the container will most likely block the incoming request until an instance becomes available.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic