This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript 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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!