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 and other Java EE Technologies and the fly likes Singleton Session Bean - PostConstruct/PreDestroy are Transactional? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Singleton Session Bean - PostConstruct/PreDestroy are Transactional?" Watch "Singleton Session Bean - PostConstruct/PreDestroy are Transactional?" New topic
Author

Singleton Session Bean - PostConstruct/PreDestroy are Transactional?

Anirudh Gupta
Ranch Hand

Joined: Dec 08, 2010
Posts: 43

PostConstruct and PreDestroy methods of Singletons with container-managed transactions are transactional.

What are the semantics of the above statement?
Why in the first place do these methods have to be in a transaction context in the first place?


Regards,
Anirudh
Joemon Anthony
Greenhorn

Joined: May 22, 2011
Posts: 23

Hi Anirudh,
As you might know that Transactional Attributes comes into picture, when your service is associated with a Transaction. If you do not want any transaction from your service then you can use NOT_SUPPORTED Transactional Attribute. But sometimes it can be useful to complete transactional activities during the PostConstruct and PreDestroy life cycle interceptor callbacks for example : logging purpose. So by making PostConstruct and PreDestroy transactional, gives freedom to the developer to write any transactional statements in that.


(SCJP 5, OCA 9i)
(Always interested in learning)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Singleton Session Bean - PostConstruct/PreDestroy are Transactional?
 
Similar Threads
Method signatures for container callbacks
suppourt for Annotation Programming . In servlets
@PostConstruct and @PreDestory
Beginning EJB 3 Application Development: From Novice to Professional - Errata
Relevance of the section "4.8.3" in the EJB 3.1 spec