• Post Reply Bookmark Topic Watch Topic
  • New Topic

ejbCreate(), create(), ejbRemove(), remove()

 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to figure out the difference between stateless and stateful session beans when it comes to ejbCreate() and ejbRemove().

If I understand it correctly:

1. When I call create() on a stateless EJB home, the container does not necessarily create a bean and calls ejbCreate() on it. Most chances are that it already has one available in the pool so what it does is find/create an EJB object, associate the bean to that EJB object, and hand me a reference to that EJB object.

2. When I call remove() on a stateless EJB object, the container does not necessarily call ejbRemove() on the bean associated with it and removes it from the container. Most chances are that it will just send the bean back to the pool and kill/cache the EJB object.

3. When I call create(parameters) on a stateful EJB home, the container does not necessarily create a bean. There are two options: it can either create a new bean, or passivate one for me. Either way, it will then unquestionably call ejbCreate(parameters) on it. This is very different from the stateless case, because even if the bean was not created but only passivated for me, ejbCreate(parameters) will still be called on it.
Then the container finds/creates an EJB object, associates the bean with that EJB object, and hands me a reference to that EJB object.

4. When I call remove() on a stateful EJB object, the container does not necessarily removes the bean associated with it. It can just send it to the pool without passivating anything. In this case the container will not call ejbRemove() on the bean.

Am I right?
[ June 12, 2007: Message edited by: Joseph Sweet ]
 
Joseph Sweet
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can nobody comment on this?

Come'on guys, drink some coffee and put your fingers to typing.

 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!