0 Replies Latest reply on Jan 4, 2005 5:57 PM by ypfamily

    EJB instance swapping question

      Hi,

      I am hoping someone can clarify this one for me.

      I was reading O'Reilly's "Enterprise JavaBeans" book and was a bit confused by the following...

      It describes how there is such a thing as an EJB object. Remote and local interfaces are implemented by this object adding container specific code that handles transactions, security and so on.

      This EJB object also either extends the bean class or simply copies the code of the developer written bean class into itself.

      Now, comes along instance pooling and the book explains that this is done by associating a bean instance with this EJB object. So, the object is always around (or a number of them are around) and the container keeps associating the a bean instance from the bean instance pool with this EJB object whenever it is needed.

      What I don't understand is how this is possible. Two possibilities are given as to how vendors might implement the relationship between the EJB object and the bean instance. I described those 2 above. In both cases, the code of the bean becomes PART of the EJB object, whether through inheritance or through just coping and pasting the code from the bean into the EJB object class.

      How is it then possible to swap instances of the bean when it appears that the EJB object already contains that instance behavior within it?

      I could have understood this if EJB object would use some sort of a Factory pattern to get a handle on an instance of the bean, but that's not what it's doing in either implementation.

      I'd appreciate your help on this one.

      Thanks,
      Yaakov.