This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Stateless Session Beans

 
Srinivasan Rengan
Ranch Hand
Posts: 122
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Ranchers,

I have this small little confusion regarding stateless session bean. Will the ejbCreate() method be called in sequel to the server creating an instance and then calling setSessionContext() or is it when the client calls create method (Just like stateful beans)...

Thanks
Srini
 
nitin goswami
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Here is your answer:

user calls create() on Stateless session bean home ->
-> new EJBObject gets created
This is the only part which happens when user calls create().

Container actually maintains a pool of stateless sessin beans. How many beans it will create totally depends on container and it do not depend on the clients create method.

But if container decides to create one than only the following steps occure :-

-> new SessionContext gets created
-> new Bean Object gets created
-> setSessionContext() gets called (it comes before ejbCreate ())
-> ejbCreate () gets called.

hope you understand what I explained.
 
cheenu Dev
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi srini..better change your name according to the naming policy.
you can view the policy here
http://www.javaranch.com/name.jsp
 
Prasanna Chennupati
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The creation of stateless session beans is not tied to client.

It is the container that decides when to create a stateless session beans.
when the container wants to create a stateless session bean, it runs the bean's constructor,setSessionContext() follwoed by ejbCreate() method.

When the client calls create() on home interface,the container just create a new EJBObject and associate that EJBObject with an instance picked from the pool.

Hope my answer clear your doubt.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic