Discussions

EJB design: must i synchronized the access to the STATEFUL session bean?

  1. must i synchronized the access to the STATEFUL session bean? (3 messages)

    hello
    there is a class named "WebClientControllerImpl" in the petstore1.3,it is a proxy between the web tier and the ejb tier,in the statement,it tell me:

    quote:
    --------------------------------------------------------------------------------
     
    all the method that access the ejb are synchronized,so that concurrent requests do not happen to the stateful session bean.

    --------------------------------------------------------------------------------

    why,i wonder if the access to the STATEFUL session bean must be synchronized?who can tell me?
    thank you!
  2. Hi,

    When u call a stateful session bean instance,
    EJB container quarantees that no other clients r using that instance.

    The container exclusively holds the bean instance and directs concurrent clients to other instances.
    or make them wait untill u'r done with that instance.

    U do not need to code u'r beans as thread safe.


    Regards
    Mushtaq
  3. The specifications states that a Stateful session bean should be dedicated to a single client. Since only one client can use the bean, concurrent access should never occur, and synchronization should be a non-issue.
  4. The specifications states that a Stateful session bean should be dedicated to a single client. Since only one client can use the bean, concurrent access should never occur, and synchronization should be a non-issue.


    Not exactly. If clients are using multiple threads it could occur.
    Also it could occur in web based applications when user click submit button several times or there are several frames send requests to the same SFSB.