> Hi:
>
> In "Mastering Enterprise Java Beans" Roman states that, and I
> quote: "When
> you call a method on a session bean instance, your EJB
> container guarantees
> that no other clients are using that instance[...]Thus, if
> multiple clients
> simultaneusly invoke methods on a session bean, they invocations are
> serialized, or performed in lock-step..." but then, in the
> Java Blueprints
> you can see things like this:
>
> "Code Example 10.14 contains an excerpt from ShoppingClientController-
> WebImpl. Notice that all the methods of ShoppingClientController are
> synchronized
> so that concurrent requests to ShoppingClientController are
> serialized.
> This is done because an EJB container will throw an exception
> if a request
> is made
> to a session bean while it is servicing another request.

I'm not sure if both behaviors are allowed or if only raising an exception
is mandated, but the end result is the same: a multithreaded client _must_
synchronize access to stateful session beans. Very irritating.


> public class ShoppingClientControllerWebImpl
> {
> private com....ejb.ShoppingClientController sccEjb;
> private HttpSession session;
> public ShoppingClientControllerWebImpl(HttpSession session) {
> this.session = session;
> ModelManager mm =
> (ModelManager)session.getAttribute("modelManager");
> sccEjb = mm.getSCCEJB();
> }
> public synchronized AccountModel getAccount() {
> CHAPTER 10 THE SAMPLE APPLICATION 288
> return sccEjb.getAccount().getDetails();
> }
> ...
> public synchronized Collection handleEvent(EStoreEvent ese) {
> return sccEjb.handleEvent(ese);
> }
> public synchronized void remove() {
> sccEjb.remove();
> }
> }
> Code Example 10.14 ShoppingClientControllerWebImpl"
>
> I'm I missing something? According to Roman the EJB container
> *guarantees*
> thread safe access to the bean instances...

Thread safe access is guaranteed, but not by having the container serialize
calls. Instead, the container throws an exception. I do wish it were
otherwise, though.


> Sorry if this a silly question, but I do see a contradiction here.

There is a contradiction. Moreover, the wrong answer is the correct one, in
my opinion, if you get my meaning.

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to