Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Question about @PostConstruct

 
Cainiao Zou
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Session Beans have a lifecycle callback function @PostConstruct, it's different than the class constructor, because it will be called later after dependence injection.
So my question is, can man call another EJB which is injected with @EJB in this lifecycle function and if yes, how about the transaction propagation? (JTA, CMT, transactional persistence context)

thanks
 
Piotr Nowicki
Ranch Hand
Posts: 611
1
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
EJB 3.1 specification, p. 374, 13.6.5 wrote:The term "an unspecified transaction context" is used in the EJB specification to refer to the cases in which the EJB architecture does not fully define the transaction semantics of an enterprise bean method execution.

This includes the following cases:
(...)
- The execution of a PostConstruct, PreDestroy, PostActivate, or PrePassivate callback method of a session bean with container-managed transaction demarcation (Except Singleton PostConstruct/PreDestroy methods)"
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic