Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

home.create and ejbCreate() ??

 
Kalpesh Soni
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
guys , i am confused
Is this sentance true ? "Whenever client calls home.create() then ejbCreate is called"
Think about stateless session beans
say the max pool size is 50
and there are 50 instances of bean
now say there are 100 clients
and no. 101 client calls home.create()
so what does container do ? pick an ejb instance of ready state and call ejbCreate() on it (That makes no sense to me) or try to make new instance (remember, the limit is reached already)
I know the story could be different for statefull/entity bean !
 
Dave Cronin
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The stateless session bean lifecycle has only two states, does not exist, and method-ready. In this lifecycle, ejbCreate is only called once. I think all that the create method does is to obtain a reference to the EJB object so as to call business methods on a pooled bean.
 
Kalpesh Soni
Ranch Hand
Posts: 312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fine
so it means that home.create() for stateless session beans would not call ejbCreate() NECESSARILY
but for statefull session beans and entity beans it has to
right ?
 
Dave Cronin
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That does seem to be the case. I could only imagine that ejbCreate would be called to add another stateless session bean to the pool. Otherwise there is no reason for the container to call ejbCreate.
As you say, ejbCreate is always called for stateful session beans and entity beans when you call create, that's mentioned in the EJB spec I believe.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmmm, my recent class notes for stateless session shows this life cycle (with a few left out)
DoesNotExist-> ejbCreate -> MethodReady -> ejbRemove -> DNE
And this for stateful
DNE -> ejbCreate -> MethodReady -> ejbPassivate -> Passive -> ejbActivate -> MethodReady -> ejbRemove -> DNE
I think going back to DNE after remove is logical, not physical. The bean instance might be put back in the pool at the container's discretion. Is the pool a requirement of the spec or a common implementation?
Still talking beyond my actual knowledge - I think the Passive state is also logical, not physical. The container might actually recycle the bean instance to another client while you're not looking.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!