Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Callbacks & Transactions in Stateful EJBs  RSS feed

 
Andriy Kharchuk
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See a quote from 'Mastering EJB 3.0' below, it's about callbacks in Stateful EJBs:

You don’t need to worry about providing methods annotated as Pre
Passivate and PostActivate callbacks unless you are using open
resources, such as socket connections or database connections, that must be
reestablished after activation.
NOTE The following rules apply to the life-cycle callback methods:
....
■■ They must not throw application exceptions, but may throw runtime
exceptions. If thrown within a transaction, it will cause the transaction
to roll back.


From what I understand, if transaction is open Stateful EBJs are never passivated. Am I missing anything?

 
massimiliano cattaneo
Greenhorn
Posts: 24
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
The State diagram of the statefull Session bean is the most complicate of all other Beans.
If the Business method is called in a transaction the Statefull goes in a "Method ready in TX" and the Passivate functionality is not available.
There are some other callback annotation that You could Use:
AfterBegin, BeforeCompletion, AfterCompletion.

Please take a look to the EJB spec at page 89

Hope this could be usefull.

 
Valery Lezhebokov
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andriy Kharchuk wrote:

From what I understand, if transaction is open Stateful EBJs are never passivated. Am I missing anything?



As massimiliano cattaneo already mentioned the SFSB life cycle is the most rich one. Here is a nice state diagram that may help to understand it:

http://sqltech.cl/doc/oas10gR31/web.1013/b28221/img/lifesfsb.gif
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!