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

Bean things can be done in ejbCreate() (stateless vs. stateful session bean)

 
Forest Lynn
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question when I was reading HFEJB book. Can any one explain why following two cases are different for accessing resource?

Based on page 196, for stateful session bean, we can access in ejbCreate()
- your special JNDI environment
- Another bean's methods
- a resource manager

However on page 228, for stateless session bean, we can only access access in ejbCreate()
- your special JNDI environment

Thanks!!
Forest Lynn
 
B.Sathish
Ranch Hand
Posts: 372
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Stateful session beans are created only when the client calls the home.create() method. But in the case of stateless session beans, the beans can be created and pooled anytime by the container, even when there is no client. For example, a container may wish to create and plop some stateless session bean instances when it is starting up. By saying that there is no necessity on the container's part to make the EJB capable of accessing another bean's methods and resource managers in ejbCreate, the specification allows the container more freedom and flexibility to create the stateless session bean instances and run its ejbCreate() whenever it wants without worrying about giving the bean resource manager access ability etc. But the container can choose to give the bean access to resource managers and other beans even in the ejbCreate() of a stateless session bean, however the spec does not mandate it. It just allows the container to optimize the creation of the stateless session bean better. But there is no need to provide this flexibility to a stateful session bean creation as the container will create it only at a fixed time, when the client calls create on the home

hth
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic