Yes, that's true for session and message-driven beans. The PostConstruct, PreDestroy, PrePassivate and PostActivate methods run in unspecified transaction and security contexts.
However, for Stateful session beans you have two minor differences: - You can call EJBContext.getCallerPrincipal() and EJBContext.isCallerInRole(). - afterBegin() and beforeCompletion() are invoked with a transaction context. This is not the same for afterCompletion() which is invoked after the transacion has completed.
For entity beans (section 3.5 of the JPA specification):
When invoked from within a Java EE environment, the callback listeners for an entity share the enterprise naming context of the invoking component, and the entity callback methods are invoked in the transaction and security contexts of the calling component at the time at which the callback method is invoked.
[ September 08, 2008: Message edited by: Sergio Tridente ]
I just want to summarize the above reply: For call back listener method: Stateless session beans: unspecified transaction context & security context Stateful session beans: unspecified transaction context & security context Entity: same trasaction & secuirty contexts. In addition, for stateful session beans: afterBegin() and beforeCompletion() - same transaction context but unspecified security context afterCompletion() - unspecified transaction & secuirty context. Please correct me if I am wrong.
But does the afterBegin() and beforeCompletion() belong to the life cycle of a Stateful session bean? In my post I've mentioned only about the lifecycle callbacks if they occur in an unspecified transaction and security context.
SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
catch it before it slithers away! Oh wait, it's a tiny ad: