Page 1 of 1
About Question enthuware.oce-ejbd.v6.2.389 :
Posted: Sun Dec 21, 2014 3:43 am
by ramy6_1
Hello ,
In case this question about statless session bean instead of stateful , I think the correct answer will be (1 or 2)
Correct ?
Re: About Question enthuware.oce-ejbd.v6.2.389 :
Posted: Sun Dec 21, 2014 9:55 am
by admin
Yes, it could be 1 or 2. Because a container is free to create multiple instances of a stateless session bean to service multiple request or it could use just one instance as well.
Re: About Question enthuware.oce-ejbd.v6.2.389 :
Posted: Fri Apr 24, 2015 6:37 pm
by himaiMinh
On p.82 of JSR-318
By default, clients are allowed to make concurrent calls to a stateful session object and the container is required to serialize such concurrent request....
That means two clients can call a method of a stateful bean. And the container will handle one client call at a time, (ie, one call after another call).
So, in this specific scenario, there is only one stateful bean and only one interceptor instance associated with that bean.
Re: About Question enthuware.oce-ejbd.v6.2.389 :
Posted: Fri Apr 24, 2015 8:38 pm
by admin
You are misinterpreting the specification. The statement that you have quoted is talking about a client making multiple concurrent calls on the same bean. Two different clients cannot use the same stateful bean. Two different clients will get two references to two different instances of the bean. If the container uses the same stateful bean instance for the two clients, the state of the bean will be messed up. For example, if one client calls method m1, another clients calls m1, and them first client calls m2, then the first client will expect the state of the bean based on its initial call to m1 but that has been messed up by another clients call to m2.