Why are ejbActivate() and ejb Passivate() included for stateless session bean even though they are never required as it is nonconversational bean

To have a consistent interface, so that there is no different interface that you need to implement for Stateful Session Bean and Stateless Session Bean. Both Stateless and Stateful Session Bean implement javax.ejb.SessionBean and this would not be possible if stateless session bean is to remove ejbActivate and ejbPassivate from the interface. You could argue that the two (stateful and stateless) are so different that they should have their own interface but Sun did not think so. They made both session beans implement the same interface and provided deployment descriptor to denote which one is it that you are deploying.

Showing Answers 1 - 1 of 1 Answers

Ginni

  • Jul 20th, 2005
 

The simple reason is to manage your resources. For eg. if you use/open any third party resource on ejbActivate, you need to make sure ejbPassivate close the connection/ release the use of resource regardless of stateful session or stateless session.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions