File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes ejbActivate and EntityContext Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "ejbActivate and EntityContext" Watch "ejbActivate and EntityContext" New topic
Author

ejbActivate and EntityContext

mini mehta
Ranch Hand

Joined: Oct 22, 2000
Posts: 120
Hi
Can anybody explain me why entity bean's ejbActivate method can't do following on EntityContext
1. get security information about client.
2. force a transaction to rollback(CMT beans)
3. find out if the transaction has already been set to rollback(CMT beans)
4. get a transaction reference, and call methods on it (BMT beans only, so entities can't use this)
Regards
Mini
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
The answer to all your questions is no due to the fact that there is no client during ejbActivate. Therefore there is no transaction.


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
mini mehta
Ranch Hand

Joined: Oct 22, 2000
Posts: 120
Originally posted by Nathaniel Stoddard:
The answer to all your questions is no due to the fact that there is no client during ejbActivate. Therefore there is no transaction.

I guess ejbActivate method of entity bean is called by container when the bean is picked up from the pool to serve a client when it invokes the entity beans business method. So there is a client during ejbActivate.
Can I ask authors of HFE to explain the above, as most of the stuff related to SessionContext and EntityContext with regards to beanness is not explained properly.
Thanks
Mini
Dale Seng
Ranch Hand

Joined: Mar 22, 2004
Posts: 275
The way I remember it (not really true "why") is to follow a bean through a lifecycle. Entity beans are CMT beans and say we were in a transaction and am about to get passivated - oops no-can-do! The only time the container would passivate me is if I was NOT in a transaction. So since the only time passivate is used is for beans not in a transaction, they don't need to get to the transaction stuff. Then for activate, I just remember that it's only logical that the bean is just on it's way back to method ready, and would have the same thing as it left with.
--Dale--
 
Don't get me started about those stupid light bulbs.
 
subject: ejbActivate and EntityContext