BackGround of Session Bean and Entity Beans


EJB design: BackGround of Session Bean and Entity Beans

  1. Is two or more users can use the same instance of a
    Session Bean or Entity Bean?.

    How the EjBContext was Handling by the WebContaineer
    for stateful Session Beans.


  2. Is two threads can use one instance of Session Bean or
    Entity Bean?

    Any reply will be highly appreciated..


  3. Gopi,

    Stateful session beans----technicaly NO
    Stateless Session beans---YES
    ENTITY BEANS--------------YES

    the container maintains a history of the contexts that have accessed a particular sharable object and when a context switching occurs it performs a look up for that particular user details...

  4. Hi sahil,

    Just now i some where in the ejb document that no two threads can use the same instance of Session or entity bean.


  5. two users/clients canuse the same instance of a stateless session bean, but not the stateful session bean.

    because when a stateful session bean goes for passivation it is passivated with session values to that particular client.and then freed.
    this is the same case applicable to entity beans too.
    container assigns seperate instances from the pool even though, the clients are accessing the same data.