This week's book giveaway is in the Python forum.
We're giving away four copies of Hello World and have Warren & Carter Sande on-line!
See this thread for details.
Win a copy of Hello World this week in the Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

home.create and ejbCreate() ??

 
Ranch Hand
Posts: 317
  • 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 !
 
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: 317
  • 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.
 
(instanceof Sidekick)
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.
 
If you have a bad day in October, have a slice of banana cream pie. And this tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!