The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes ejbCreate in stateful session bean Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "ejbCreate in stateful session bean" Watch "ejbCreate in stateful session bean" New topic

ejbCreate in stateful session bean

Ranganathan Kaliyur Mannar

Joined: Oct 16, 2003
Posts: 1101

The container is supposed to maintain a pool of beans. Let's say there are 10 stateful session beans ready in a pool. During the creation of these 10 objects, the container would have called setSessionContext and ejbCreate().
As it is stateful session beans, let's say I write some code in ejbCreate that is going to setup my state initially which is crucial for my bean.

Now, when the client calls homeObject.create(), even though the bean has been already created and is present in the pool, will the container make a call to setSessionContext and ejbCreate?

Thank You,

Shreyas Reddy
Ranch Hand

Joined: Oct 09, 2003
Posts: 49
Unlike stateless session beans a pool is not maintained for stateful session beans. SFSB are created as the requests for the new beans come in.
Here is the flow for SFSB creation. I hope it helps:

client calls create on home
container makes EJBObject and session context
container constructs bean instance and links the bean to its ctx and ejbobject
container sends the client a stub to the ejbobject
... methods invocation
client calls remove on either componenet or home interface
container calls ejbREmove on the b ean
container kills the bean and EJBobject
Ranganathan Kaliyur Mannar

Joined: Oct 16, 2003
Posts: 1101

It's clear now.

Thanks for explaining.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: ejbCreate in stateful session bean
It's not a secret anymore!